NMI on a Commodore 64 using DurexForth #343
Replies: 5 comments 1 reply
-
; nmi handler
lab_fe47
pha ; save a
txa ; copy x
pha ; save x
tya ; copy y
pha ; save y
lda #$7f ; disable all interrupts
sta lab_dd0d ; save via 2 icr
ldy lab_dd0d ; save via 2 icr
bmi lab_fe72 ; The linchpin So everything depends on whether or not the high bit is set on the read of $ddod, CIA 2 interrupt control register. restore_handler
pha ; save a
txa ; copy x
pha ; save x
tya ; copy y
pha ; save y
lda #$7f ; disable all interrupts
sta $dd0d ;
ldy $dd0d ; save cia 2 icr
bpl stop_restore ; if high bit not set
kernal_nmi
jmp $fe72
stop_restore
jsr $f6bc ; increment real time clock
; scan stop key
lda $91 ; read the stop key column
cmp #$7f ; compare with [stp] down
; if not [stp] or not just [stp] exit
bne kernal_nmi ; if not [stop] restore registers and exit interrupt
brk_handler
pla
pla
tax ; restore xr for QUIT
jmp QUIT
quit_reset ; execute once at start
sei
lda #<restore_handler
sta $318
lda #>restore_handler
sta $319
lda #<brk_handler
sta $316
lda #>brk_handler
sta $317
keep_nmi
cli ; still have to Questions? |
Beta Was this translation helpful? Give feedback.
-
This deserves reiteration. The only requirement for QUIT is a valid data stack pointer x. |
Beta Was this translation helpful? Give feedback.
-
The only requirement for jmp $fe72 the kernal NMI routine, |
Beta Was this translation helpful? Give feedback.
-
QUIT on Release v2.0.0.0, QUIT
jsr quit_reset ; Changed to keep_nmi so as to not reset the NMI vector
; resets the return stack *** preserve x ***
txa
INIT_S = * + 1
ldx #0
txs
tax ; data stack pointer
interpret_loop
jsr REFILL
jsr interpret_tib
jmp interpret_loop
|
Beta Was this translation helpful? Give feedback.
-
NMI on Release v2.0.0.0,
from interpreter.asm
Simply changing the NMI vector wouldn't work because QUIT resets the vector.
So, to enable RS-232, I employed a patch on quit_reset:
Voila! We have RS-232. And side effects.
Note that any NMI not initiated by CIA 2 (RS-232)
is handled the same way as Restore key
This is Kernal source:
1: As long as the Kernal ROM is in context, this executes before jumping thru the NMI vector
2: On Restore key, this will restart DurexForth if booted from cart- bad.
3: this does the restart. We don't want this.
4: scan stop key
<> 0 Restore key only,
= 0 run/stop Restore
5: This seems harmless enough
Beta Was this translation helpful? Give feedback.
All reactions