Beispiel #1
0
 public void executeInstruction(Instruction instr)
 {
     if (instr == null) {
         Console.WriteLine("Non-existant instruction; skipping");
         programCounter++;
         return;
     }
     List<byte> operands = new List<byte>();
     for (int i = 1; i < instr.length; i++) {
         operands.Add(readHighNibble(assembly[programCounter + i]));
         operands.Add(readLowNibble(assembly[programCounter + i]));
     }
     if (instr.opcode != 0xA) {
         instr.execute(ms, operands.ToArray());
         programCounter += currentInstruction.length;
     } else {
         programCounter = instr.execute(ms, operands.ToArray(), programCounter);
     }
 }
Beispiel #2
0
 public void loadAssembly()
 {
     //currentInstruction = instructions.Where(i => i.opcode == readLowNibble(assembly[0]) && i.cond == readHighNibble(assembly[1])).First();
     currentInstruction =
         instructions.First(i => i.accept(readHighNibble(assembly[0]), readLowNibble(assembly[0])));
 }
Beispiel #3
0
 public Instruction fetchAndDecodeInstruction()
 {
     int high = readHighNibble(assembly[programCounter]);
     int low = readLowNibble(assembly[programCounter]);
     currentInstruction = instructions.FirstOrDefault(instr => instr.accept(high, low)) ?? new Instruction();
     return currentInstruction;
 }