preserve 0x1xx stack for main task, and restore on quit
This commit is contained in:
parent
c428ef3d9c
commit
b2d374622a
|
@ -13,9 +13,10 @@
|
|||
(global long BootHandle-e1)
|
||||
(fn boot ()
|
||||
(asm (clc) (xce) (rep 0x30)) ; disable emulation mode, 16-bit index registers
|
||||
(save-dp-sp)
|
||||
(save-dp-sp 0x0800)
|
||||
(set-task-base 0x0800) ; space for 8 tasks
|
||||
|
||||
(save-6502-stack)
|
||||
|
||||
; http://www.1000bit.it/support/manuali/apple/technotes/pdos/tn.pdos.27.html
|
||||
; When bootstrapping with no OS, we must reserve
|
||||
(TLStartUp)
|
||||
|
@ -39,6 +40,7 @@
|
|||
|
||||
(MTShutDown)
|
||||
|
||||
(restore-6502-stack)
|
||||
(restore-dp-sp)
|
||||
(asm (sec) (xce)) ; re-enter emulation mode
|
||||
))
|
||||
|
|
|
@ -9,9 +9,11 @@
|
|||
(global word old-dp 0)
|
||||
(global word old-sp 0)
|
||||
|
||||
(form save-dp-sp [#[:block [:tdc] [:sta :old-dp] [:tsc] [:sta :old-sp]]])
|
||||
(form save-dp-sp [#[:block [:tdc] [:sta :old-dp] [:tsc] [:sta :old-sp]]])
|
||||
(form restore-dp-sp [#[:block [:lda :old-dp] [:tcd] [:lda :old-sp] [:tcs]]])
|
||||
|
||||
(form save-6502-stack [#[:block [:tsc] [:tay] [:and 0xff] [:ora 0x100] [:tax] [:eor 0xffff] [:clc] [:adc 0x200] [:mvn 0 0]]])
|
||||
(form restore-6502-stack [#[:block [:tsc] [:tax] [:and 0xff] [:ora 0x100] [:tay] [:eor 0xffff] [:clc] [:adc 0x200] [:mvn 0 0]]])
|
||||
; 0x1ef = 0x1ef-0x1ff = 0x0f -> 0x7f
|
||||
(const task-size 0x100)
|
||||
(global word first-task)
|
||||
(global word last-task)
|
||||
|
@ -19,7 +21,7 @@
|
|||
(form set-task-base [(fn [ssc task-base]
|
||||
[:block [:lda task-base] [:tcd]
|
||||
[:sta ssc.TASK-NEXT] [:sta :first-task] [:sta :last-task]
|
||||
[:lda (+ task-base 0xff)] [:tcs]])])
|
||||
[:tsc] [:and 0xff] [:ora task-base] [:tcs]])])
|
||||
|
||||
(fn yield ()
|
||||
(asm (tsc) (sta [$1.TASK-STACK])
|
||||
|
|
Loading…
Reference in a new issue