public override void Process(ICpuStateOperations cpuStateManager) { var programCounter = cpuStateManager.IncrementProgramCounter(); this.nextWordAddress = cpuStateManager.ReadMemoryValueAtAddress(programCounter); this.registerValue = cpuStateManager.ReadGeneralPursoseRegisterValue((ushort)(this.OperandValue % NumberOfRegisters)); }
public override void Write(ICpuStateOperations cpuStateManager, ushort value) { var stackPointerValue = cpuStateManager.DecrementStackPointer(); if (cpuStateManager.ReadMemoryValueAtAddress(stackPointerValue) != 0x0) { throw new Exception("DCPU16 Stack overflow"); } cpuStateManager.WriteMemoryValueAtAddress(stackPointerValue, value); }
public Instruction Build(ushort instructionValue, ICpuStateOperations cpuState) { if (this.instructionCache.Keys.Contains(instructionValue)) { return this.instructionCache[instructionValue]; } this.rawInstruction = instructionValue; this.opcode = (ushort)(rawInstruction & OpMask); if (this.opcode == 0) { var op = (ushort)((instructionValue >> OperandAShift) & OperandAMask); if (op == 0x01) { var operandValue = (ushort)((instructionValue >> OperandBShift) & OperandBMask); this.operationA = new CpuOperation(this.operandFactory.Create(operandValue), cpuState); this.operationB = null; var jsrInstruction = new JsrInstruction(0, this.operationA, this.operationA); this.instructionCache[instructionValue] = jsrInstruction; return jsrInstruction; } return null; } var firstOperandValue = (ushort)((instructionValue >> OperandAShift) & OperandAMask); var secondOperandValue = (ushort)((instructionValue >> OperandBShift) & OperandBMask); this.operationA = new CpuOperation(this.operandFactory.Create(firstOperandValue), cpuState); this.operationB = new CpuOperation(this.operandFactory.Create(secondOperandValue), cpuState); var instruction = this.instructionMapper[(BasicOpcode)this.opcode](); this.instructionCache[instructionValue] = instruction; return instruction; }
public virtual void Write(ICpuStateOperations cpuStateManager, ushort value) { throw new InvalidOperationException(); }
public virtual void Process(ICpuStateOperations cpuStateManager) { }
public override void NoOp(ICpuStateOperations cpuStateManager) { cpuStateManager.IncrementProgramCounter(); }
public override void Process(ICpuStateOperations cpuStateManager) { this.literal = (ushort)((this.OperandValue - 0x20) % NumberOfLiterals); }
public override void Write(ICpuStateOperations cpuStateManager, ushort value) { cpuStateManager.WriteGeneralPursoseRegisterValue(this.OperandValue, value); }
public override void Write(ICpuStateOperations cpuStateManager, ushort value) { cpuStateManager.SetProgramCounter(value); }
public override ushort Read(ICpuStateOperations cpuStateManager) { return cpuStateManager.Overflow; }
public override ushort Read(ICpuStateOperations cpuStateManager) { return (ushort)(cpuStateManager.ReadMemoryValueAtAddress((ushort)(this.nextWordAddress + this.registerValue)) & ShortMask); }
public override void Process(ICpuStateOperations cpuStateManager) { this.registerValue = cpuStateManager.ReadGeneralPursoseRegisterValue((ushort)(this.OperandValue % NumberOfRegisters)); }
public override ushort Read(ICpuStateOperations cpuStateManager) { throw new InvalidOperationException(); }
public override ushort Read(ICpuStateOperations cpuStateManager) { return cpuStateManager.ReadMemoryValueAtAddress(this.registerValue); }
public override ushort Read(ICpuStateOperations cpuStateManager) { return cpuStateManager.StackPointer; }
public override void Write(ICpuStateOperations cpuStateManager, ushort value) { cpuStateManager.WriteMemoryValueAtAddress((this.nextWordAddress + this.registerValue) & Operand.ShortMask, value); }
public virtual void NoOp(ICpuStateOperations cpuStateManager) { }
public override ushort Read(ICpuStateOperations cpuStateManager) { return cpuStateManager.ReadMemoryValueAtAddress(cpuStateManager.StackPointer); }
public CpuOperation(Operand operand, ICpuStateOperations cpuStateManager) { this.operand = operand; this.cpuStateManager = cpuStateManager; }
public override void Write(ICpuStateOperations cpuStateManager, ushort value) { cpuStateManager.SetStackPointer(value); }
public override void Write(ICpuStateOperations cpuStateManager, ushort value) { cpuStateManager.Overflow = value; }
public override ushort Read(ICpuStateOperations cpuStateManager) { return cpuStateManager.ReadMemoryValueAtAddress(this.nextWordAddress); }
public override ushort Read(ICpuStateOperations cpuStateManager) { return cpuStateManager.ReadGeneralPursoseRegisterValue(this.OperandValue); }
public override void Write(ICpuStateOperations cpuStateManager, ushort value) { cpuStateManager.WriteMemoryValueAtAddress(this.nextWordAddress, value); }
public override ushort Read(ICpuStateOperations cpuStateManager) { return cpuStateManager.ProgramCounter; }
public override void Process(ICpuStateOperations cpuStateManager) { var programCounter = cpuStateManager.IncrementProgramCounter(); this.nextWordAddress = cpuStateManager.ReadMemoryValueAtAddress(programCounter); }
public override ushort Read(ICpuStateOperations cpuStateManager) { cpuStateManager.IncrementProgramCounter(); var value = cpuStateManager.ReadValueAtProgramCounter(); return value; }
public virtual ushort Read(ICpuStateOperations cpuStateManager) { throw new InvalidOperationException(); }
public override ushort Read(ICpuStateOperations cpuStateManager) { var value = cpuStateManager.ReadMemoryValueAtAddress(cpuStateManager.StackPointer); cpuStateManager.IncrementStackPointer(); return value; }
public override ushort Read(ICpuStateOperations cpuStateManager) { return this.literal; }