Esempio n. 1
0
 public long GetLiteral(Punchcard pc)
 {
     if (Mode == Mode.Position || Mode == Mode.Immediate)
     {
         return(Value);
     }
     else
     {
         return(RelativeBase + Value);
     }
 }
Esempio n. 2
0
        public long GetResult(Punchcard pc)
        {
            switch (Mode)
            {
            case Mode.Position:
                return(pc.GetAddress(Value));

            case Mode.Immediate:
                return(Value);

            case Mode.Relative:
                int newAdd = RelativeBase + (int)Value;
                return(pc.GetAddress(newAdd));

            default: return(-999);
            }
        }
Esempio n. 3
0
 public IntCodeComputer(List <long> instructions)
 {
     Pointer = 0;
     PC      = new Punchcard(instructions);
 }