static PropertyInfo GetPropertyInfo(InstructionMnemonic im) { var propertyInfo = typeof(ISA).GetProperty(im.ToString(), BindingFlags.Public | BindingFlags.Static); return(propertyInfo); }
public InstructionMetadata(InstructionMnemonic instructionMnemonic, int opcode, int function, InstructionFormat format) { Instruction = instructionMnemonic; Format = format; OpCode = opcode; Function = function; }
public static InstructionJ Emit(InstructionMnemonic mnemonic, int address) { var instruction = ISA.GetInstruction (mnemonic); if (instruction.Format != InstructionFormat.J) { throw new Exception ("Wrong instruction type."); } return new InstructionJ { Instruction = instruction.Instruction, OpCode = instruction.OpCode, Address = address }; }
public static InstructionJ Emit(InstructionMnemonic mnemonic, int address) { var instruction = ISA.GetInstruction(mnemonic); if (instruction.Format != InstructionFormat.J) { throw new Exception("Wrong instruction type."); } return(new InstructionJ { Instruction = instruction.Instruction, OpCode = instruction.OpCode, Address = address }); }
public static InstructionI Emit(InstructionMnemonic mnemonic, CpuReg rs, CpuReg rt, int immediate) { var instruction = ISA.GetInstruction (mnemonic); if (instruction.Format != InstructionFormat.I) { throw new Exception ("Wrong instruction type."); } return new InstructionI { Instruction = instruction.Instruction, OpCode = instruction.OpCode, Rs = rs, Rt = rt, Immediate = immediate }; }
public static InstructionR Emit(InstructionMnemonic mnemonic, CpuReg rs, CpuReg rt, CpuReg rd, int shamt) { var instruction = ISA.GetInstruction (mnemonic); if (instruction.Format != InstructionFormat.R) { throw new Exception ("Wrong instruction type."); } return new InstructionR { Instruction = instruction.Instruction, OpCode = instruction.OpCode, Rs = rs, Rt = rt, Rd = rd, Shamt = shamt, Funct = instruction.Function }; }
public static InstructionI Emit(InstructionMnemonic mnemonic, CpuReg rs, CpuReg rt, int immediate) { var instruction = ISA.GetInstruction(mnemonic); if (instruction.Format != InstructionFormat.I) { throw new Exception("Wrong instruction type."); } return(new InstructionI { Instruction = instruction.Instruction, OpCode = instruction.OpCode, Rs = rs, Rt = rt, Immediate = immediate }); }
public static InstructionR Emit(InstructionMnemonic mnemonic, CpuReg rs, CpuReg rt, CpuReg rd, int shamt) { var instruction = ISA.GetInstruction(mnemonic); if (instruction.Format != InstructionFormat.R) { throw new Exception("Wrong instruction type."); } return(new InstructionR { Instruction = instruction.Instruction, OpCode = instruction.OpCode, Rs = rs, Rt = rt, Rd = rd, Shamt = shamt, Funct = instruction.Function }); }
static PropertyInfo GetPropertyInfo(InstructionMnemonic im) { var propertyInfo = typeof(ISA).GetProperty (im.ToString (), BindingFlags.Public | BindingFlags.Static); return propertyInfo; }
internal static InstructionMetadata GetInstruction(InstructionMnemonic im) { var propertyInfo = GetPropertyInfo (im); return (InstructionMetadata)propertyInfo.GetValue (null, null); }
public bool ExecuteInstruction() { InstructionMnemonic instruction = InstructionDecoder.Decode(ComputerMemory[PC]); string pc = PC.ToString("X4"); _logger.Debug($"{pc} {instruction}"); switch (instruction) { case InstructionMnemonic.ACI: // add immediate with carry AddImmediateWithCarry(); break; case InstructionMnemonic.ADC: // add with carry AddWithCarry(); break; case InstructionMnemonic.ADD: // add Add(); break; case InstructionMnemonic.ADI: // add immediate AddImmediate(); break; case InstructionMnemonic.ANA: // and with accumulator LogicalAndWithAccumulator(); break; case InstructionMnemonic.ANI: AndImmediateWithAccumulator(); break; case InstructionMnemonic.CALL: // subroutine call Call(); break; case InstructionMnemonic.CC: // subroutine call if carry CallIfCarry(); break; case InstructionMnemonic.CM: // subroutine call if minus CallIfMinus(); break; case InstructionMnemonic.CMA: // complement accumulator ComplementAccoumulator(); break; case InstructionMnemonic.CMC: // complement carry ComplementCarry(); break; case InstructionMnemonic.CMP: // compare with accumulator CompareWithAccumulator(); break; case InstructionMnemonic.CNC: // call if no carry CallIfNoCarry(); break; case InstructionMnemonic.CNZ: // call if not zero CallIfNotZero(); break; case InstructionMnemonic.CP: // call if positive CallIfPositive(); break; case InstructionMnemonic.CPE: // call if parity even CallIfParityEven(); break; case InstructionMnemonic.CPI: // compare immediate CompareImmediate(); break; case InstructionMnemonic.CPO: // call if parity odd CallIfParityOdd(); break; case InstructionMnemonic.CZ: // call if zero CallIfZero(); break; case InstructionMnemonic.DAA: // decimal adjust accumulator DecimalAdjustAccumulator(); break; case InstructionMnemonic.DAD: // double register add DoubleRegisterAdd(); break; case InstructionMnemonic.DCR: // decrement Decrement(); break; case InstructionMnemonic.DCX: // decrement register pair DecrementRegisterPair(); break; case InstructionMnemonic.DI: DisableInterrupts(); break; case InstructionMnemonic.EI: EnableInterrupts(); break; case InstructionMnemonic.HLT: return(false); case InstructionMnemonic.IN: GetInput(); break; case InstructionMnemonic.INR: IncrementRegister(); break; case InstructionMnemonic.INX: IncrementRegisterPair(); break; case InstructionMnemonic.JC: JumpIfCarry(); break; case InstructionMnemonic.JM: JumpIfMinus(); break; case InstructionMnemonic.JMP: Jump(); break; case InstructionMnemonic.JNC: JumpIfNoCarry(); break; case InstructionMnemonic.JNZ: JumpIfNotZero(); break; case InstructionMnemonic.JP: JumpIfPositive(); break; case InstructionMnemonic.JPE: JumpIfParityEven(); break; case InstructionMnemonic.JPO: JumpIfParityOdd(); break; case InstructionMnemonic.JZ: JumpIfZero(); break; case InstructionMnemonic.LDA: LoadAccumulatorDirect(); break; case InstructionMnemonic.LDAX: LoadAccumulatorIndirect(); break; case InstructionMnemonic.LHLD: LoadHLDirect(); break; case InstructionMnemonic.LXI: LoadRegisterPairImmediate(); break; case InstructionMnemonic.MOV: // move Move(); break; case InstructionMnemonic.MVI: MoveImmediate(); break; case InstructionMnemonic.NOP: // no operation PC++; break; case InstructionMnemonic.ORA: InclusiveORWithAccumulator(); break; case InstructionMnemonic.ORI: InclusiveOrImmediate(); break; case InstructionMnemonic.OUT: SendOutput(); break; case InstructionMnemonic.PCHL: MoveHLToPC(); break; case InstructionMnemonic.POP: Pop(); break; case InstructionMnemonic.PUSH: Push(); break; case InstructionMnemonic.RAL: RotateLeftThroughCarry(); break; case InstructionMnemonic.RAR: RotateRightThroughCarry(); break; case InstructionMnemonic.RC: ReturnIfCarry(); break; case InstructionMnemonic.RET: Return(); break; case InstructionMnemonic.RIM: ReadInterruptMask(); break; case InstructionMnemonic.RLC: RotateAccumulatorLeft(); break; case InstructionMnemonic.RM: ReturnIfMinus(); break; case InstructionMnemonic.RNC: ReturnIfNoCarry(); break; case InstructionMnemonic.RNZ: ReturnIfNotZero(); break; case InstructionMnemonic.RP: ReturnIfPositive(); break; case InstructionMnemonic.RPE: ReturnIfParityEven(); break; case InstructionMnemonic.RPO: ReturnIfParityOdd(); break; case InstructionMnemonic.RRC: RotateAccumulatorRight(); break; case InstructionMnemonic.RST: // get the AAA address from the RST instruction Restart(); break; case InstructionMnemonic.RZ: ReturnIfZero(); break; case InstructionMnemonic.SBB: SubtractWithBorrow(); break; case InstructionMnemonic.SBI: SubtractImmediateWithBorrow(); break; case InstructionMnemonic.SHLD: StoreHLDirect(); break; case InstructionMnemonic.SIM: SetInterruptMask(); break; case InstructionMnemonic.SPHL: MoveHLToSP(); break; case InstructionMnemonic.STA: StoreAccumulatorDirect(); break; case InstructionMnemonic.STAX: StoreAccumulatorIndirect(); break; case InstructionMnemonic.STC: Flags.Carry = true; break; case InstructionMnemonic.SUB: Subtract(); break; case InstructionMnemonic.SUI: SubtractImmediate(); break; case InstructionMnemonic.XCHG: ExchangeHLandDE(); break; case InstructionMnemonic.XRA: ExclusiveOrWithAccumulator(); break; case InstructionMnemonic.XRI: ExclusiveOrImmediate(); break; case InstructionMnemonic.XTHL: ExchangeXLWithTopOfStack(); break; default: throw new NotImplementedException(); } return(true); }
public int TStates(InstructionMnemonic instruction) { switch (instruction) { case InstructionMnemonic.NOP: break; case InstructionMnemonic.HLT: break; case InstructionMnemonic.MOV: break; case InstructionMnemonic.CALL: break; case InstructionMnemonic.ANA: break; case InstructionMnemonic.CC: break; case InstructionMnemonic.CNC: break; case InstructionMnemonic.CZ: break; case InstructionMnemonic.CNZ: break; case InstructionMnemonic.CP: break; case InstructionMnemonic.CM: break; case InstructionMnemonic.CPE: break; case InstructionMnemonic.CPO: break; case InstructionMnemonic.RET: break; case InstructionMnemonic.RC: break; case InstructionMnemonic.RNC: break; case InstructionMnemonic.RZ: break; case InstructionMnemonic.RNZ: break; case InstructionMnemonic.RP: break; case InstructionMnemonic.RM: break; case InstructionMnemonic.RPE: break; case InstructionMnemonic.RPO: break; case InstructionMnemonic.RST: break; case InstructionMnemonic.IN: break; case InstructionMnemonic.OUT: break; case InstructionMnemonic.LXI: break; case InstructionMnemonic.PUSH: break; case InstructionMnemonic.POP: break; case InstructionMnemonic.STA: break; case InstructionMnemonic.LDA: break; case InstructionMnemonic.XCHG: break; case InstructionMnemonic.XTHL: break; case InstructionMnemonic.SPHL: break; case InstructionMnemonic.PCHL: break; case InstructionMnemonic.DAD: break; case InstructionMnemonic.STAX: break; case InstructionMnemonic.LDAX: break; case InstructionMnemonic.INX: break; case InstructionMnemonic.MVI: break; case InstructionMnemonic.INR: break; case InstructionMnemonic.DCR: break; case InstructionMnemonic.ADD: break; case InstructionMnemonic.ADC: break; case InstructionMnemonic.SUB: break; case InstructionMnemonic.SBB: break; case InstructionMnemonic.XRA: break; case InstructionMnemonic.ORA: break; case InstructionMnemonic.CMP: break; case InstructionMnemonic.ADI: break; case InstructionMnemonic.ACI: break; case InstructionMnemonic.SUI: break; case InstructionMnemonic.SBI: break; case InstructionMnemonic.ANI: break; case InstructionMnemonic.XRI: break; case InstructionMnemonic.ORI: break; case InstructionMnemonic.CPI: break; case InstructionMnemonic.RLC: break; case InstructionMnemonic.RRC: break; case InstructionMnemonic.RAL: break; case InstructionMnemonic.RAR: break; case InstructionMnemonic.JMP: break; case InstructionMnemonic.JC: break; case InstructionMnemonic.JNC: break; case InstructionMnemonic.JZ: break; case InstructionMnemonic.JNZ: break; case InstructionMnemonic.JP: break; case InstructionMnemonic.JM: break; case InstructionMnemonic.JPE: break; case InstructionMnemonic.JPO: break; case InstructionMnemonic.DCX: break; case InstructionMnemonic.CMA: break; case InstructionMnemonic.STC: break; case InstructionMnemonic.CMC: break; case InstructionMnemonic.DAA: break; case InstructionMnemonic.SHLD: break; case InstructionMnemonic.LHLD: break; case InstructionMnemonic.RIM: break; case InstructionMnemonic.SIM: break; case InstructionMnemonic.EI: break; case InstructionMnemonic.DI: break; } return(0); }
internal static InstructionMetadata GetInstruction(InstructionMnemonic im) { var propertyInfo = GetPropertyInfo(im); return((InstructionMetadata)propertyInfo.GetValue(null, null)); }