示例#1
0
 private void Set(GhostOperand operand, byte value, bool allowPc = false)
 {
     switch (operand.Type)
     {
         case GhostOperandType.ConstantIndirect:
             this.data[operand.Value] = value;
             break;
         case GhostOperandType.Register:
             this.registers[operand.Value] = value;
             break;
         case GhostOperandType.RegisterIndirect:
             this.data[this.registers[operand.Value]] = value;
             break;
         default:
             if (allowPc && operand.Type == GhostOperandType.ProgramCounter)
             {
                 pc = value;
                 break;
             }
             throw new Exception();
     }
 }
示例#2
0
 private byte Get(GhostOperand operand)
 {
     switch (operand.Type)
     {
         case GhostOperandType.ProgramCounter:
             return pc;
         case GhostOperandType.Constant:
             return operand.Value;
         case GhostOperandType.ConstantIndirect:
             return this.data[operand.Value];
         case GhostOperandType.Register:
             return this.registers[operand.Value];
         case GhostOperandType.RegisterIndirect:
             return this.data[this.registers[operand.Value]];
         default:
             throw new Exception();
     }
 }