use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Test method testCLC.
@Test
public void testCLC() {
Program program = new Program().with(SEC, CLC);
memory.setBlock(0, program.getProgramAsByteArray());
Registers registers = processor.getRegisters();
processor.step();
assert (processor.getRegisters().getFlag(Registers.Flag.CARRY));
processor.step();
assertEquals(program.getLength(), registers.getPC());
assertEquals(false, registers.getFlag(Registers.Flag.CARRY));
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Test method testBPL.
@Test
public void testBPL() {
Program program = new Program().with(LDA_I, 0b00000001, BPL, 0x4, LDA_I, 0x99, LDX_I, 0x98, LDY_I, 0x97);
memory.setBlock(0, program.getProgramAsByteArray());
Registers registers = processor.getRegisters();
processor.step(3);
assertEquals(program.getLength(), registers.getPC());
assertEquals(0b00000001, registers.getRegister(Registers.Register.ACCUMULATOR));
assertEquals(0x0, registers.getRegister(Registers.Register.X_INDEX));
assertEquals(0x97, registers.getRegister(Registers.Register.Y_INDEX));
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Test method testLDX.
@Test
public void testLDX() {
Program program = new Program().with(LDX_I, 0xAA);
memory.setBlock(0, program.getProgramAsByteArray());
processor.step();
Registers registers = processor.getRegisters();
assertEquals(0xAA, registers.getRegister(Registers.Register.X_INDEX));
assertEquals(0x0, 0);
assertEquals(program.getLength(), registers.getPC());
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Test method testMultiplicationLoop.
@Test
public void testMultiplicationLoop() {
int data_offset = 0x32;
int MPD = data_offset + 0x10;
int MPR = data_offset + 0x11;
int TMP = data_offset + 0x20;
int RESAD_0 = data_offset + 0x30;
int RESAD_1 = data_offset + 0x31;
int valMPD = 7;
int valMPR = 4;
Program program = new Program().with(LDA_I, valMPD, STA_Z, MPD, LDA_I, valMPR, STA_Z, MPR, // <---- start
LDA_I, // <---- start
0, // Clear
STA_Z, // Clear
TMP, // ...
STA_Z, // ...
RESAD_0, // ...
STA_Z, // ...
RESAD_1, // X counts each bit
LDX_I, // X counts each bit
8, // :MULT(18) LSR(MPR)
LSR_Z, // :MULT(18) LSR(MPR)
MPR, // Test carry and jump (forward 13) to NOADD
BCC, // Test carry and jump (forward 13) to NOADD
13, // RESAD -> A
LDA_Z, // RESAD -> A
RESAD_0, // Prepare to add
CLC, // +MPD
ADC_Z, // +MPD
MPD, // Save result
STA_Z, // Save result
RESAD_0, // RESAD+1 -> A
LDA_Z, // RESAD+1 -> A
RESAD_1, // +TMP
ADC_Z, // +TMP
TMP, // RESAD+1 <- A
STA_Z, // RESAD+1 <- A
RESAD_1, // :NOADD(35) ASL(MPD)
ASL_Z, // :NOADD(35) ASL(MPD)
MPD, // Save bit from MPD
ROL_Z, // Save bit from MPD
TMP, // --X
DEX, // Test equal and jump (back 24) to MULT
BNE, // Test equal and jump (back 24) to MULT
0b11100111);
memory.setBlock(0, program.getProgramAsByteArray());
Registers registers = processor.getRegisters();
processor.step(27);
assertEquals(0x1C, memory.getByte(RESAD_0));
}
use of com.rox.emu.processor.mos6502.util.Program in project emuRox by rossdrew.
the class Mos6502Test method testDEX.
@Test
public void testDEX() {
Program program = new Program().with(LDX_I, 0x01, DEX);
memory.setBlock(0, program.getProgramAsByteArray());
Registers registers = processor.getRegisters();
processor.step();
assert (processor.getRegisters().getRegister(Registers.Register.X_INDEX) == 1);
processor.step();
assertEquals(program.getLength(), registers.getPC());
assertEquals(0, processor.getRegisters().getRegister(Registers.Register.X_INDEX));
}
Aggregations