public void Call(Processor processor) { var mdr = processor[Register.MemoryData]; var dest = (Register)(mdr >> 9 & 0b111); var sr1 = (Register)(mdr >> 6 & 0b111); var leftVal = processor[sr1]; var fromImmediate = mdr >> 5 & 1; int rightVal; if (fromImmediate == 1) { rightVal = mdr & 0b1_1111; if (Program.Disassemble) { Console.WriteLine($"ADD\t{dest}, {sr1}, #{rightVal:X}"); } } else { var sr2 = (Register)(mdr & 0b111); rightVal = processor[sr2]; if (Program.Disassemble) { Console.WriteLine($"ADD\t{dest}, {sr1}, {sr2}"); } } var result = (short)(leftVal + rightVal); processor[dest] = result; processor[Register.Flag] = BR.MapResult(result); }
public void Call(Processor processor) { var mdr = processor[Register.MemoryData]; var register = (Register)(mdr >> 9 & 0b111); var value = mdr & 0b1_1111_1111; var result = (short)(processor[Register.PC] + (short)value); processor[register] = result; processor[Register.Flag] = BR.MapResult(result); if (Program.Disassemble) { Console.WriteLine($"LEA\t{register}, #{value:X}"); } }
public void Call(Processor processor) { var mdr = processor[Register.MemoryData]; var register = (Register)(mdr >> 9 & 0b111); var ptr = mdr & 0b1_1111_1111; var result = (short)processor.Memory[processor.Memory[ptr]]; processor[register] = result; processor[Register.Flag] = BR.MapResult(result); if (Program.Disassemble) { Console.WriteLine($"LDI\t{register}, #{ptr:X}"); } }
public void Call(Processor processor) { var mdr = processor[Register.MemoryData]; var offset = mdr & 0b11_1111; var baseRegister = (Register)(mdr >> 6 & 0b111); var dest = (Register)(mdr >> 9 & 0b111); var result = (short)processor.Memory[processor[baseRegister] + offset]; processor[dest] = result; processor[Register.Flag] = BR.MapResult(result); if (Program.Disassemble) { Console.WriteLine($"LDR\t{dest}, {baseRegister}, #{offset:X}"); } }