Пример #1
0
        /// <summary>
        /// Executes an operation on the ALU
        /// Reads the input value from the X- and Y-Bus on the processor
        /// </summary>
        /// <param name="op">The operation to execute</param>
        /// <param name="affectFlags">If true, affects the status-register-flags</param>
        public void Execute(Cmd op, bool affectFlags)
        {
            IAluCommand aluCommand = GetAluCommand(op);

            if (aluCommand != null)
            {
                Res = aluCommand.Execute();
                if (affectFlags)
                {
                    SetFlags(aluCommand);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Set the flags in the status register of the processor
        /// </summary>
        /// <param name="op">Operation which was executed</param>
        private void SetFlags(IAluCommand aluCommand)
        {
            // Zero Flag
            proc.Z = Res == 0;

            // Sign Flag
            proc.S = (Res & MSB) == MSB;

            if (aluCommand != null)
            {
                aluCommand.SetFlags(proc);
            }
            else
            {
                proc.O = false;
            }
        }