NoIRQ1: jsr callmain
-; Back from main (this is also the _exit entry). Reset the IRQ vector if we
+; Back from main (this is also the _exit entry). Reset the IRQ vector if we
; chained it.
_exit: pha ; Save the return code on stack
NoIRQ2: jsr donelib
-; Reset the stack
-
- ldx spsave
- txs
-
; Copy back the zero page stuff
ldx #zpspace-1
dex
bpl L2
-; Reset the memory configuration
-
- lda mmusave
- sta MMU_CR
-
; Place the program return code into ST
pla
sta ST
+; Reset the stack and the memory configuration
+
+ ldx spsave
+ txs
+ ldx mmusave
+ stx MMU_CR
+
; Done, restore kernal vectors in an attempt to cleanup
jmp RESTOR
_exit: pha ; Save the return code on stack
jsr donelib ; Run module destructors
-; Restore system stuff
-
- ldx spsave
- txs
-
; Copy back the zero page stuff
ldx #zpspace-1
pla
sta ST
+; Restore the stack pointer
+
+ ldx spsave
+ txs
+
; Reset changed vectors
jmp RESTOR
_exit: pha ; Save the return code
jsr donelib ; Run module destructors
-; Restore system stuff
-
- ldx spsave
- txs ; Restore stack pointer
- lda mmusave
- sta $01 ; Restore memory configuration
-
; Copy back the zero page stuff
ldx #zpspace-1
pla
sta ST
+; Restore system stuff
+
+ ldx spsave
+ txs ; Restore stack pointer
+ ldx mmusave
+ stx $01 ; Restore memory configuration
+
; Reset changed vectors, back to basic
jmp RESTOR
_exit: pha ; Save the return code on stack
jsr donelib ; Run module destructors
-; Restore system stuff
-
- ldx spsave
- txs ; Restore stack pointer
-
; Copy back the zero page stuff
ldx #zpspace-1
pla
sta ST
+; Restore the stack pointer
+
+ ldx spsave
+ txs ; Restore stack pointer
+
; Back to basic
rts
sta irqcount ; Disable custom IRQ handlers
jsr donelib ; Run module destructors
-; Restore system stuff
-
- ldx spsave
- txs
-
; Copy back the zero page stuff
ldx #zpspace-1
pla
sta ST
+; Restore the stack pointer
+
+ ldx spsave
+ txs
+
; Enable the ROM, reset changed vectors and return to BASIC
sta ENABLE_ROM
_exit: pha ; Save the return code on stack
jsr donelib ; Run module destructors
-; Restore system stuff
-
- ldx spsave
- txs ; Restore stack pointer
-
; Copy back the zero page stuff
ldx #zpspace-1
pla
sta ST
+; Restore the stack pointer
+
+ ldx spsave
+ txs
+
; Reset changed vectors, back to basic
jmp RESTOR