Simplified test code for X and Y regs, added additional JSR test

This commit is contained in:
Brendan Robert 2024-02-10 15:09:52 -06:00
parent 7b78521920
commit a3e9a44254
2 changed files with 31 additions and 8 deletions

View File

@ -305,11 +305,8 @@ public class TestProgram {
String condition = "X != %s <<%s>>".formatted(Integer.toHexString(val), caller);
_test("""
PHP
PHA
TXA
CMP #%s
CPX #%s
BNE ++
PLA
PLP
BRA +
++ ; Error
@ -324,11 +321,8 @@ public class TestProgram {
String condition = "Y != %s <<%s>>".formatted(Integer.toHexString(val), caller);
_test("""
PHP
PHA
TYA
CMP #%s
CPY #%s
BNE ++
PLA
PLP
BRA +
++ ; Error

View File

@ -765,6 +765,7 @@ public class Full65C02Test {
/* Test JSR */
@Test
public void testJsr() throws ProgramException {
// "Easy" test that JSR + RTS work as expected and together take 12 cycles
new TestProgram()
.add("""
jmp +
@ -776,5 +777,33 @@ public class Full65C02Test {
JSR sub1
""", 12)
.run();
// Check that JSR pushes the expected PC values to the stack
new TestProgram()
.add("""
jmp start
test
plx
ply
phy
phx
rts
""")
.test("", "RTS did not return to the correct address")
.add("""
start
+traceOn
jsr test
ret
""")
.test("""
cpy #>ret
beq +
""", "Y = MSB of return address")
.test("""
inx
cpx #<ret
beq +
""", "X = LSB of return address-1")
.run();
}
}