예제 #1
0
 /*
  * - ADD $m	Add the value in memory to the accumulator
  * - ADD #$val     Add the value to the accumulator
  */
 private static void ADD(CPU cpu, Boolean immediate, short operand)
 {
     short acc = cpu.getRegisterValue(2);
     if (immediate)
     {
         cpu.setRegisterValue(2, (short)(acc + operand));
     }
     else
     {
         short value = (short)cpu.getMemory().getMemoryLocation(operand);
         cpu.setRegisterValue(2, (short)(acc + value));
     }
 }
예제 #2
0
 /*
  * - SHL #$val Shift the accumulator by the number of bits to the left
  */
 private static void SHL(CPU cpu, short operand)
 {
     short acc = cpu.getRegisterValue(2);
     cpu.setRegisterValue(2, (short)(acc << operand));
 }
예제 #3
0
 /*
  * - NOTA		Logical "not" of accumulator
  */
 private static void NOTA(CPU cpu)
 {
     short acc = cpu.getRegisterValue(2);
     cpu.setRegisterValue(2, (short)~cpu.getRegisterValue(2));
 }
예제 #4
0
 /*
  * - LDA #$val Sets the accumulator with the value
  * - LDA $m	Sets the accumulator from a memory location
  */
 private static void LDA(CPU cpu, Boolean immediate, short operand)
 {
     if (immediate)
     {
         cpu.setRegisterValue(2, operand);
     }
     else
     {
         cpu.setRegisterValue(2, (short)cpu.getMemory().getMemoryLocation(operand));
     }
 }
예제 #5
0
 /*
  * - BL lbl        Branch to label if operation resulted in Negative
  */
 private static void BL(CPU cpu, short operand)
 {
     short acc = cpu.getRegisterValue(2);
     if (acc < 0)
     {
         cpu.setRegisterValue(5, operand);
     }
 }
예제 #6
0
 /*
  * - BA lbl        Always branch to label (goto)
  */
 private static void BA(CPU cpu, short operand)
 {
     cpu.setRegisterValue(5, operand);
 }