Skip to content

Commit

Permalink
[MONITOR] fix entry by command in 65C816 emulation mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mooinglemur committed Mar 11, 2024
1 parent 85878c1 commit 5844b42
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion monitor/monitor.s
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,18 @@ monitor:
phy
bra @end
@basic:
; For 65C816 emulated mode
; in the case of BRK, __irq_65c816 pushes things in this order
; (original real RTI-style return)
; .B, .A, .D (two bytes), .DB, rombank, ret h, ret l, .P
; .A (dummy copy of rombank), .X, .Y

; For 65C02
; We were called from BASIC
; in the case of BRK, the RAM __irq pushes things in this order
; (original real RTI-style return)
; A, rombank, ret h, ret l, P, A (dummy copy of ret l), X, Y
; .A, rombank, ret h, ret l, .P, .A (dummy copy of ret l), .X, .Y

; load the values from BASIC as this is our best guess
; which assumes MONITOR was called explicitly rather than
; via a BRK instruction.
Expand All @@ -231,8 +239,25 @@ monitor:
phx
lda $030f
pha

; Skip over pushing 65C816 stack if running on a 65C02
sec
.byte $c2, $03
bcs @basic_cont_c02

lda #0
pha
pha
pha
lda $030c
pha
lda #0
pha
bra @basic_cont_c816
@basic_cont_c02:
lda $030c
pha
@basic_cont_c816:
lda bank_ro
pha
phy
Expand Down

0 comments on commit 5844b42

Please sign in to comment.