/* * - 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)); } }
/* * - 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)); }
/* * - NOTA Logical "not" of accumulator */ private static void NOTA(CPU cpu) { short acc = cpu.getRegisterValue(2); cpu.setRegisterValue(2, (short)~cpu.getRegisterValue(2)); }
/* * - 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)); } }
/* * - 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); } }
/* * - BA lbl Always branch to label (goto) */ private static void BA(CPU cpu, short operand) { cpu.setRegisterValue(5, operand); }