From 9c685d5b6ca1686f944fb239ec89511f24801d44 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Sun, 6 Sep 2026 21:42:34 +0200 Subject: vnf: also set the carry on a zero compare MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add also a test to further check corner cases on compare instructions. Signed-off-by: Miquel Sabaté Solà --- tests/expected/runrom/cmp.txt | 18 ++++++++++++++++++ tests/runrom/cmp.s | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 tests/expected/runrom/cmp.txt create mode 100644 tests/runrom/cmp.s (limited to 'tests') diff --git a/tests/expected/runrom/cmp.txt b/tests/expected/runrom/cmp.txt new file mode 100644 index 0000000..e76570b --- /dev/null +++ b/tests/expected/runrom/cmp.txt @@ -0,0 +1,18 @@ + PC: $8000, cycles: 7, registers: [a: $00, x: $00, y: $00, sp: $FD], status: ----I-- +lda #$00 PC: $8002, cycles: 9, registers: [a: $00, x: $00, y: $00, sp: $FD], status: ----IZ- +sta $00 PC: $8004, cycles: 12, registers: [a: $00, x: $00, y: $00, sp: $FD], status: ----IZ- +cmp $00 PC: $8006, cycles: 15, registers: [a: $00, x: $00, y: $00, sp: $FD], status: ----IZC +inc $00 PC: $8008, cycles: 20, registers: [a: $00, x: $00, y: $00, sp: $FD], status: ----I-C +cmp $00 PC: $800A, cycles: 23, registers: [a: $00, x: $00, y: $00, sp: $FD], status: N---I-- +lda #$02 PC: $800C, cycles: 25, registers: [a: $02, x: $00, y: $00, sp: $FD], status: ----I-- +cmp $00 PC: $800E, cycles: 28, registers: [a: $02, x: $00, y: $00, sp: $FD], status: ----I-C +lda #$01 PC: $8010, cycles: 30, registers: [a: $01, x: $00, y: $00, sp: $FD], status: ----I-C +cmp $00 PC: $8012, cycles: 33, registers: [a: $01, x: $00, y: $00, sp: $FD], status: ----IZC +lda #$FF PC: $8014, cycles: 35, registers: [a: $FF, x: $00, y: $00, sp: $FD], status: N---I-C +cmp $00 PC: $8016, cycles: 38, registers: [a: $FF, x: $00, y: $00, sp: $FD], status: N---I-C +rts PC: $8017, cycles: 44, registers: [a: $FF, x: $00, y: $00, sp: $FD], status: N---I-C + + +== Memory dump == + +[$0] = $01 [reads=6, writes=2] diff --git a/tests/runrom/cmp.s b/tests/runrom/cmp.s new file mode 100644 index 0000000..29deda3 --- /dev/null +++ b/tests/runrom/cmp.s @@ -0,0 +1,37 @@ +.segment "HEADER" + .byte 'N', 'E', 'S', $1A + .byte $02, $01 + .byte $00 + .byte $00 + +.segment "CHARS" +.byte 0 + +.segment "VECTORS" + .addr reset, reset, reset + +.segment "CODE" +;; asan:stack full + +zp_mem = $00 + +.proc reset + lda #0 + sta zp_mem + + cmp zp_mem + + inc zp_mem + cmp zp_mem + + lda #2 + cmp zp_mem + + lda #1 + cmp zp_mem + + lda #$FF + cmp zp_mem + + rts +.endproc -- cgit v1.2.3