private bool ExecuteOTHEROperation(Command operation) { operation.Activate(DataBuses.NONE); previousActivatedCommandsListBox.Items.Add(operation); switch (operation.Code) { case 1: registerPC.Value++; return(true); case 2: registerSP.Value++; return(true); case 3: registerSP.Value--; return(true); case 4: FLAGSRegister.SetFlags(VirtualRegRBUS.Value); return(true); case 5: FLAGSRegister.SetFlag(ProcessorSimulator.Controls.Flags.FlagsRegister.Flags.CF, false); return(true); case 6: FLAGSRegister.SetFlag(ProcessorSimulator.Controls.Flags.FlagsRegister.Flags.VF, false); return(true); case 7: FLAGSRegister.SetFlag(ProcessorSimulator.Controls.Flags.FlagsRegister.Flags.ZF, false); return(true); case 8: FLAGSRegister.SetFlag(ProcessorSimulator.Controls.Flags.FlagsRegister.Flags.SF, false); return(true); case 9: return(true); case 10: FLAGSRegister.SetFlag(ProcessorSimulator.Controls.Flags.FlagsRegister.Flags.CF, true); return(true); case 11: FLAGSRegister.SetFlag(ProcessorSimulator.Controls.Flags.FlagsRegister.Flags.VF, true); return(true); case 12: FLAGSRegister.SetFlag(ProcessorSimulator.Controls.Flags.FlagsRegister.Flags.ZF, true); return(true); case 13: FLAGSRegister.SetFlag(ProcessorSimulator.Controls.Flags.FlagsRegister.Flags.SF, true); return(true); case 14: return(true); default: return(false); } }
private bool ExecuteAluOperation(Command operation) { operation.Activate(DataBuses.NONE); previousActivatedCommandsListBox.Items.Add(operation); int s, d; if (VirtualRegSBUS.Value > short.MaxValue) { s = (int)((short)VirtualRegSBUS.Value); } else { s = (int)((short)VirtualRegSBUS.Value); } if (VirtualRegDBUS.Value > short.MaxValue) { d = (int)((short)VirtualRegDBUS.Value); } else { d = (int)((short)VirtualRegDBUS.Value); } switch (operation.Code) { case 1: { int res = s + d; VirtualRegRBUS.Value = ConvertToUnsignedShort(res); return(true); } case 2: { int res = s & d; VirtualRegRBUS.Value = ConvertToUnsignedShort(res); return(true); } case 3: { int res = s | d; VirtualRegRBUS.Value = ConvertToUnsignedShort(res); return(true); } case 4: { int res = s ^ d; VirtualRegRBUS.Value = ConvertToUnsignedShort(res); return(true); } case 5: { int res = ~d; VirtualRegRBUS.Value = ConvertToUnsignedShort(res); return(true); } case 6: { int res = d / 2; VirtualRegRBUS.Value = ConvertToUnsignedShort(res); return(true); } case 7: { int res = d * 2; VirtualRegRBUS.Value = ConvertToUnsignedShort(res); return(true); } case 8: { int res = d >> 1; VirtualRegRBUS.Value = ConvertToUnsignedShort(res); return(true); } case 9: { int res = d << 1 | (d >> 15 & 0x0001); VirtualRegRBUS.Value = ConvertToUnsignedShort(res); return(true); } case 10: { int res = d >> 1 | ((d & 0x0001) << 15); VirtualRegRBUS.Value = ConvertToUnsignedShort(res); return(true); } case 11: { int res = d << 1 | (FLAGSRegister.GetFlag(ProcessorSimulator.Controls.Flags.FlagsRegister.Flags.CF) ? 0x0001 : 0x0000); FLAGSRegister.SetFlag(ProcessorSimulator.Controls.Flags.FlagsRegister.Flags.CF, (d & 0x1000) == 1 ? true : false); VirtualRegRBUS.Value = ConvertToUnsignedShort(res); return(true); } case 12: { int res = d >> 1 | (FLAGSRegister.GetFlag(ProcessorSimulator.Controls.Flags.FlagsRegister.Flags.CF) ? 0x1000 : 0x0000); FLAGSRegister.SetFlag(ProcessorSimulator.Controls.Flags.FlagsRegister.Flags.CF, (d & 0x0001) == 1 ? true : false); VirtualRegRBUS.Value = ConvertToUnsignedShort(res); return(true); } case 13: { int res = d - s; VirtualRegRBUS.Value = ConvertToUnsignedShort(res); return(true); } default: return(false); } }