mirror of
https://github.com/sethm/symon.git
synced 2024-06-03 07:29:30 +00:00
a9c6d5964f
* Add 65C02 Opcode tests * All tests pass, Klaus' 6502_functional_tests pass & Klaus' 65C02_extended_opcodes_test also all pass
73 lines
2.2 KiB
Java
73 lines
2.2 KiB
Java
package com.loomcom.symon;
|
|
|
|
import com.loomcom.symon.devices.Memory;
|
|
import com.loomcom.symon.exceptions.MemoryAccessException;
|
|
import junit.framework.*;
|
|
|
|
import static junit.framework.TestCase.assertFalse;
|
|
import static org.junit.Assert.assertEquals;
|
|
import static org.junit.Assert.assertTrue;
|
|
|
|
/**
|
|
* Test for Zero Page Indirect addressing mode, found on some instructions
|
|
* in the 65C02 and 65816
|
|
*/
|
|
public class Cpu65C02ImmediateModeTest extends TestCase {
|
|
protected Cpu cpu;
|
|
protected Bus bus;
|
|
protected Memory mem;
|
|
|
|
private void makeCmosCpu() throws Exception {
|
|
makeCpu(InstructionTable.CpuBehavior.CMOS_6502);
|
|
}
|
|
|
|
private void makeNmosCpu() throws Exception {
|
|
makeCpu(InstructionTable.CpuBehavior.NMOS_6502);
|
|
}
|
|
|
|
private void makeCpu(InstructionTable.CpuBehavior behavior) throws Exception {
|
|
this.cpu = new Cpu(behavior);
|
|
this.bus = new Bus(0x0000, 0xffff);
|
|
this.mem = new Memory(0x0000, 0xffff);
|
|
bus.addCpu(cpu);
|
|
bus.addDevice(mem);
|
|
|
|
// Load the reset vector.
|
|
bus.write(0xfffc, Bus.DEFAULT_LOAD_ADDRESS & 0x00ff);
|
|
bus.write(0xfffd, (Bus.DEFAULT_LOAD_ADDRESS & 0xff00) >>> 8);
|
|
|
|
cpu.reset();
|
|
}
|
|
|
|
public void test_BIT_Immediate() throws Exception {
|
|
makeCmosCpu();
|
|
bus.loadProgram(0x89, 0xF1); // 65C02 BIT #$01
|
|
cpu.setAccumulator(0x02);
|
|
|
|
cpu.step();
|
|
assertTrue(cpu.getZeroFlag()); // #$02 & #$F1 = 0
|
|
assertEquals(0x02,cpu.getAccumulator()); // Accumulator should not be modified
|
|
assertFalse(cpu.getNegativeFlag()); // BIT #Immediate should not set N or V Flags
|
|
assertFalse(cpu.getOverflowFlag());
|
|
|
|
cpu.reset();
|
|
cpu.setAccumulator(0x01);
|
|
cpu.step();
|
|
assertFalse(cpu.getZeroFlag()); // #$F1 & #$01 = 1
|
|
assertEquals(0x01,cpu.getAccumulator());
|
|
|
|
}
|
|
|
|
public void test_BIT_ImmediateRequiresCmosCpu() throws Exception {
|
|
makeNmosCpu();
|
|
bus.loadProgram(0x89, 0xF1); // 65C02 BIT #$01
|
|
|
|
cpu.step();
|
|
cpu.setAccumulator(0x01);
|
|
assertTrue(cpu.getZeroFlag());
|
|
assertEquals(0x01,cpu.getAccumulator());
|
|
|
|
}
|
|
|
|
}
|