65816: Emulation mode stack wrapping
ElectronicsTinkerer opened this issue · 2 comments
Stack Operations Tests
Since all of these instructions (PLD, RTL, PHD, PER, PEI, PEA, JSL) are "new" instructions and deal with page wrapping in emulation mode, I've combined them all into a single issue. These tests check to see if the 2- or 3-byte value pushed in emulation mode page wraps or not. Each test shows the source code and the relevant memory dump(s) before and after each case is run. Each test indicates that these should not page wrap, contrary to the expected behavior of as of commit 96c2c8a. (Not wrapping is consistent with this source)
If you see a mistake in my testing, let me know and I can re-run the tests.
Test results for PLD
Test condition: "2b e xx"
Verdict: PLD
does not page wrap
Source code:
stack_save .equ $1000
.as
.org 0
lda #0 ; Set the DBR to a known value
pha
plb
.al
rep #$20 ; Save the stack so we can return to MONTIOR
tsc
sta >stack_save
.as
sec ; Emulation mode
xce
.as
.xs
;; ENTER EMULATION MODE
;; TEST: "2b e xx"
ldx #$fe ; SP = $1fe
txs
lda #1
sta |$101 ; 1
inc
sta |$100 ; 2
inc
sta |$ff ; 3
inc
sta |$201 ; 4
inc
sta |$200 ; 5
inc
sta |$1ff ; 6
pld
ldx #$f0 ; "non-controversial" value (no stack wrapping)
txs
phd
plx
pla
;; EXIT EMULATION MODE
clc ; Back to Native mode
xce
stx $202 ; Here's our value to look at
sta $203
.al
rep #$20
lda >stack_save ; Restore stack
tcs
rtl ; MONITOR prints A on return
Hardware trace:
[ ZEDIAC ] > 0.200
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
000000: A9 00 48 AB C2 20 3B 8F 00 10 00 38 FB A2 FE 9A ..H.. ;....8....
000010: A9 01 8D 01 01 1A 8D 00 01 1A 8D FF 00 1A 8D 01 ................
000020: 02 1A 8D 00 02 1A 8D FF 01 2B A2 F0 9A 0B FA 68 .........+.....h
000030: 18 FB 8E 80 00 8D 81 00 C2 20 AF 00 10 00 1B 6B ......... .....k
000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[ ZEDIAC ] > gosub 0
249
[ ZEDIAC ] > 0.200
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
000000: A9 00 48 AB C2 20 3B 8F 00 10 00 38 FB A2 FE 9A ..H.. ;....8....
000010: A9 01 8D 01 01 1A 8D 00 01 1A 8D FF 00 1A 8D 01 ................
000020: 02 1A 8D 00 02 1A 8D FF 01 2B A2 F0 9A 0B FA 68 .........+.....h
000030: 18 FB 8E 80 00 8D 81 00 C2 20 AF 00 10 00 1B 6B ......... .....k
000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000080: 06 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 ................
000100: 02 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 ................
0001F0: 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 06 ................
000200: 05 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Test results for RTL
Test condition: "6b e xx"
Verdict: RTL
does not page wrap
Source code:
stack_save .equ $1000
.as
.org 0
lda #0 ; Set the DBR to a known value
pha
plb
.al
rep #$20 ; Save the stack so we can return to MONTIOR
tsc
sta >stack_save
.as
sec ; Emulation mode
xce
.as
.xs
;; ENTER EMULATION MODE
;; TEST: "6b e xx"
ldx #$ff ; SP = $1ff
txs
lda #$20-1 ; If rtl does not wrap, will return to $220
sta |$200
lda #$02
sta |$201
lda #0
sta |$202
lda #$10-1 ; If rtl does wrap, will return to $110
sta |$100
lda #$01
sta |$101
lda #0
sta |$102
rtl
;; EXIT EMULATION MODE
cleanup:
clc ; Back to Native mode
xce
.al
rep #$20
lda >stack_save ; Restore stack
tcs
txa ; Get return value
rtl ; MONITOR prints A on return
.org $110
.xs
ldx #$1
jmp cleanup
.org $220
.xs
ldx #$2
jmp cleanup
Hardware trace:
[ ZEDIAC ] > 0.220
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
000000: A9 00 48 AB C2 20 3B 8F 00 10 00 38 FB A2 FF 9A ..H.. ;....8....
000010: A9 1F 8D 00 02 A9 02 8D 01 02 A9 00 8D 02 02 A9 ................
000020: 0F 8D 00 01 A9 01 8D 01 01 A9 00 8D 02 01 6B 18 ..............k.
000030: FB C2 20 AF 00 10 00 1B 8A 6B 00 00 00 00 00 00 .. ......k......
000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000110: A2 01 4C 2F 00 00 00 00 00 00 00 00 00 00 00 00 ..L/............
000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000210: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000220: A2 02 4C 2F 00 00 00 00 00 00 00 00 00 00 00 00 ..L/............
[ ZEDIAC ] > gosub 0 <-- JSL 0
2 <-- Value in A
Test results for PHD
Test condition: "0b e 15"
Verdict: PHD
does not page wrap
Source code:
stack_save .equ $1000
.as
.org 0
lda #0 ; Set the DBR to a known value
pha
plb
.al
rep #$20 ; Save the stack so we can return to MONTIOR
tsc
sta >stack_save
.as
sec ; Emulation mode
xce
.as
.xs
;; ENTER EMULATION MODE
lda #$26
sta $180
lda #$d8
sta $181
ldx #$7f ; SP = $017f
txs
pld ; Get the D value
ldx #$00
txs
phd ;
;; EXIT EMULATION MODE
clc ; Back to Native mode
xce
.al
rep #$20
lda >stack_save ; Restore stack
tcs
rtl ; MONITOR prints A on return
Hardware trace:
[ ZEDIAC ] > 0.200
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
000000: A9 00 48 AB C2 20 3B 8F 00 10 00 38 FB A9 26 8D ..H.. ;....8..&.
000010: 80 01 A9 D8 8D 81 01 A2 7F 9A 2B A2 00 9A 0B 18 ..........+.....
000020: FB C2 20 AF 00 10 00 1B 6B 00 00 00 00 00 00 00 .. .....k.......
000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[ ZEDIAC ] > gosub 0
0
[ ZEDIAC ] > 0.200
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
000000: A9 00 48 AB C2 20 3B 8F 00 10 00 38 FB A9 26 8D ..H.. ;....8..&.
000010: 80 01 A9 D8 8D 81 01 A2 7F 9A 2B A2 00 9A 0B 18 ..........+.....
000020: FB C2 20 AF 00 10 00 1B 6B 00 00 00 00 00 00 00 .. .....k.......
000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 26 ...............&
000100: D8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000180: 26 D8 00 00 00 00 00 00 00 00 00 00 00 00 00 00 &...............
000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Test results for PER
Test condition: "62 e xx"
Verdict: PER
does not page wrap
Source code:
stack_save .equ $1000
.as
.org 0
lda #0 ; Set the DBR to a known value
pha
plb
.al
rep #$20 ; Save the stack so we can return to MONTIOR
tsc
sta >stack_save
.as
sec ; Emulation mode
xce
.as
.xs
;; ENTER EMULATION MODE
;; "62 e xx"
ldx #$00
txs
per $76ae
;; EXIT EMULATION MODE
clc ; Back to Native mode
xce
.al
rep #$20
lda >stack_save ; Restore stack
tcs
rtl ; MONITOR prints A on return
Hardware trace:
[ ZEDIAC ] > 0.200
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
000000: A9 00 48 AB C2 20 3B 8F 00 10 00 38 FB A2 00 9A ..H.. ;....8....
000010: 62 AE 76 18 FB C2 20 AF 00 10 00 1B 6B 00 00 00 b.v... .....k...
000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[ ZEDIAC ] > gosub 0
249
[ ZEDIAC ] > 0.200
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
000000: A9 00 48 AB C2 20 3B 8F 00 10 00 38 FB A2 00 9A ..H.. ;....8....
000010: 62 AE 76 18 FB C2 20 AF 00 10 00 1B 6B 00 00 00 b.v... .....k...
000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 C1 ................
000100: 76 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 v...............
000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Test results for PEI
Test condition: "d4 e xx"
Verdict: PEI
does not page wrap
Source code:
stack_save .equ $1000
.as
.org 0
lda #0 ; Set the DBR to a known value
pha
plb
.al
rep #$20 ; Save the stack so we can return to MONTIOR
tsc
sta >stack_save
.as
sec ; Emulation mode
xce
.as
.xs
;; ENTER EMULATION MODE
;; "d4 e xx"
lda #$30
sta $f0
lda #$56
sta $f1
ldx #$00
txs
pei ($f0)
;; EXIT EMULATION MODE
clc ; Back to Native mode
xce
.al
rep #$20
lda >stack_save ; Restore stack
tcs
rtl ; MONITOR prints A on return
Hardware trace:
[ ZEDIAC ] > 0.200
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
000000: A9 00 48 AB C2 20 3B 8F 00 10 00 38 FB A9 30 85 ..H.. ;....8..0.
000010: F0 A9 56 85 F1 A2 00 9A D4 F0 18 FB C2 20 AF 00 ..V.......... ..
000020: 10 00 1B 6B 00 00 00 00 00 00 00 00 00 00 00 00 ...k............
000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[ ZEDIAC ] > gosub 0
249
[ ZEDIAC ] > 0.200
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
000000: A9 00 48 AB C2 20 3B 8F 00 10 00 38 FB A9 30 85 ..H.. ;....8..0.
000010: F0 A9 56 85 F1 A2 00 9A D4 F0 18 FB C2 20 AF 00 ..V.......... ..
000020: 10 00 1B 6B 00 00 00 00 00 00 00 00 00 00 00 00 ...k............
000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 30 ...............0
000100: 56 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 V...............
000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Test results for PEA
Test condition: "f4 e 790"
Verdict: PEA
does not page wrap
Source code:
stack_save .equ $1000
.as
.org 0
lda #0 ; Set the DBR to a known value
pha
plb
.al
rep #$20 ; Save the stack so we can return to MONTIOR
tsc
sta >stack_save
.as
sec ; Emulation mode
xce
.as
.xs
;; ENTER EMULATION MODE
;; "f4 e 790"
ldx #$00
txs
pea $648c
;; EXIT EMULATION MODE
clc ; Back to Native mode
xce
.al
rep #$20
lda >stack_save ; Restore stack
tcs
rtl ; MONITOR prints A on return
Hardware trace:
[ ZEDIAC ] > 0.200
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
000000: A9 00 48 AB C2 20 3B 8F 00 10 00 38 FB A2 00 9A ..H.. ;....8....
000010: F4 8C 64 18 FB C2 20 AF 00 10 00 1B 6B 00 00 00 ..d... .....k...
000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[ ZEDIAC ] > gosub 0
249
[ ZEDIAC ] > 0.200
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
000000: A9 00 48 AB C2 20 3B 8F 00 10 00 38 FB A2 00 9A ..H.. ;....8....
000010: F4 8C 64 18 FB C2 20 AF 00 10 00 1B 6B 00 00 00 ..d... .....k...
000020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 8C ................
000100: 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d...............
000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Test results for JSL
Test condition: "22 e xx"
Verdict: JSL
does page wrap
Source code:
stack_save .equ $1000
.as
.org $40000
lda #0 ; Set the DBR to a known value
pha
plb
.al
rep #$20 ; Save the stack so we can return to MONTIOR
tsc
sta >stack_save
.as
sec ; Emulation mode
xce
.as
.xs
;; ENTER EMULATION MODE
;; "22 e xx"
ldx #$01
txs
jsl $20134
.org $134 ; Will be placed into correct bank on load
;; EXIT EMULATION MODE
clc ; Back to Native mode
xce
.al
rep #$20
lda >stack_save ; Restore stack
tcs
rtl ; MONITOR prints A on return
Hardware trace:
[ ZEDIAC ] > 40000.40010
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
040000: A9 00 48 AB C2 20 3B 8F 00 10 00 38 FB A2 01 9A ..H.. ;....8....
040010: 22 34 01 02 00 00 00 00 00 00 00 00 00 00 00 00 "4..............
[ ZEDIAC ] > 20134
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
020130: 00 00 00 00 18 FB C2 20 AF 00 10 00 1B 6B 00 00 ....... .....k..
[ ZEDIAC ] > f0.200
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
[ ZEDIAC ] > gosub 40000
249
[ ZEDIAC ] > f0.200
00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
0000F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 13 ................
000100: 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000110: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000120: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000130: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000140: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000150: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000170: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000190: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001A0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001B0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001C0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001D0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001E0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0001F0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
Apologies, just to flag it in case I'm acting under a misapprehension — based on your leading conclusion that "Each test indicates that these should not page wrap" and the before/after memory dumps showing a 13
deposited at 0000FF
, I'm taking "Verdict: JSL does page wrap" as a typo.
So JSL
counts as a new instruction, not an old one.
Otherwise, thanks so much for this bug report plus the other two! All are being addressed.
Ah—good catch. JSL
counts as a new instruction, not an old one, so it should read "Verdict: JSL does not page wrap," as you suggested.