mirror of
https://github.com/irmen/prog8.git
synced 2025-02-19 11:31:07 +00:00
added sys.exit2 and sys.exit3 to set more result registers at program exit
todo
This commit is contained in:
parent
52649a8e4f
commit
f739e679e4
@ -256,6 +256,22 @@ save_SCRATCH_ZPWORD2 .word 0
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub exit2(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y) {
|
||||||
|
; -- immediately exit the program with result values in the A, X and Y registers.
|
||||||
|
; TODO where to store A,X,Y as exit code?
|
||||||
|
%asm {{
|
||||||
|
jmp exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub exit3(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y, bool carry @Pc) {
|
||||||
|
; -- immediately exit the program with result values in the A, X and Y registers, and the Carry flag in the status register.
|
||||||
|
; TODO where to store A,X,Y,Carry as exit code?
|
||||||
|
%asm {{
|
||||||
|
jmp exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
inline asmsub progend() -> uword @AY {
|
inline asmsub progend() -> uword @AY {
|
||||||
%asm {{
|
%asm {{
|
||||||
lda #<prog8_program_end
|
lda #<prog8_program_end
|
||||||
|
@ -377,8 +377,15 @@ asmsub cleanup_at_exit() {
|
|||||||
sta $ff00 ; default bank 15
|
sta $ff00 ; default bank 15
|
||||||
jsr cbm.CLRCHN ; reset i/o channels
|
jsr cbm.CLRCHN ; reset i/o channels
|
||||||
jsr enable_runstop_and_charsetswitch
|
jsr enable_runstop_and_charsetswitch
|
||||||
|
_exitcodeCarry = *+1
|
||||||
|
lda #0
|
||||||
|
lsr a
|
||||||
_exitcode = *+1
|
_exitcode = *+1
|
||||||
lda #0 ; exit code possibly modified in exit()
|
lda #0 ; exit code possibly modified in exit()
|
||||||
|
_exitcodeX = *+1
|
||||||
|
ldx #0
|
||||||
|
_exitcodeY = *+1
|
||||||
|
ldy #0
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -764,6 +771,33 @@ _longcopy
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub exit2(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y) {
|
||||||
|
; -- immediately exit the program with result values in the A, X and Y registers.
|
||||||
|
%asm {{
|
||||||
|
sta cleanup_at_exit._exitcode
|
||||||
|
stx cleanup_at_exit._exitcodeX
|
||||||
|
sty cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub exit3(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y, bool carry @Pc) {
|
||||||
|
; -- immediately exit the program with result values in the A, X and Y registers, and the Carry flag in the status register.
|
||||||
|
%asm {{
|
||||||
|
sta cleanup_at_exit._exitcode
|
||||||
|
lda #0
|
||||||
|
rol a
|
||||||
|
sta cleanup_at_exit._exitcodeCarry
|
||||||
|
stx cleanup_at_exit._exitcodeX
|
||||||
|
sty cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
inline asmsub progend() -> uword @AY {
|
inline asmsub progend() -> uword @AY {
|
||||||
%asm {{
|
%asm {{
|
||||||
lda #<prog8_program_end
|
lda #<prog8_program_end
|
||||||
|
@ -376,8 +376,15 @@ asmsub cleanup_at_exit() {
|
|||||||
sta $01 ; bank the kernal in
|
sta $01 ; bank the kernal in
|
||||||
jsr cbm.CLRCHN ; reset i/o channels
|
jsr cbm.CLRCHN ; reset i/o channels
|
||||||
jsr enable_runstop_and_charsetswitch
|
jsr enable_runstop_and_charsetswitch
|
||||||
|
_exitcodeCarry = *+1
|
||||||
|
lda #0
|
||||||
|
lsr a
|
||||||
_exitcode = *+1
|
_exitcode = *+1
|
||||||
lda #0 ; exit code possibly modified in exit()
|
lda #0 ; exit code possibly modified in exit()
|
||||||
|
_exitcodeX = *+1
|
||||||
|
ldx #0
|
||||||
|
_exitcodeY = *+1
|
||||||
|
ldy #0
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -762,6 +769,33 @@ _longcopy
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub exit2(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y) {
|
||||||
|
; -- immediately exit the program with result values in the A, X and Y registers.
|
||||||
|
%asm {{
|
||||||
|
sta cleanup_at_exit._exitcode
|
||||||
|
stx cleanup_at_exit._exitcodeX
|
||||||
|
sty cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub exit3(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y, bool carry @Pc) {
|
||||||
|
; -- immediately exit the program with result values in the A, X and Y registers, and the Carry flag in the status register.
|
||||||
|
%asm {{
|
||||||
|
sta cleanup_at_exit._exitcode
|
||||||
|
lda #0
|
||||||
|
rol a
|
||||||
|
sta cleanup_at_exit._exitcodeCarry
|
||||||
|
stx cleanup_at_exit._exitcodeX
|
||||||
|
sty cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
inline asmsub progend() -> uword @AY {
|
inline asmsub progend() -> uword @AY {
|
||||||
%asm {{
|
%asm {{
|
||||||
lda #<prog8_program_end
|
lda #<prog8_program_end
|
||||||
|
@ -1289,8 +1289,15 @@ asmsub cleanup_at_exit() {
|
|||||||
sta $01 ; rom bank 4 (basic)
|
sta $01 ; rom bank 4 (basic)
|
||||||
stz $2d ; hack to reset machine code monitor bank to 0
|
stz $2d ; hack to reset machine code monitor bank to 0
|
||||||
jsr cbm.CLRCHN ; reset i/o channels
|
jsr cbm.CLRCHN ; reset i/o channels
|
||||||
|
_exitcodeCarry = *+1
|
||||||
|
lda #0
|
||||||
|
lsr a
|
||||||
_exitcode = *+1
|
_exitcode = *+1
|
||||||
lda #0 ; exit code possibly modified in exit()
|
lda #0 ; exit code possibly modified in exit()
|
||||||
|
_exitcodeX = *+1
|
||||||
|
ldx #0
|
||||||
|
_exitcodeY = *+1
|
||||||
|
ldy #0
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -1655,6 +1662,33 @@ save_SCRATCH_ZPWORD2 .word 0
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub exit2(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y) {
|
||||||
|
; -- immediately exit the program with result values in the A, X and Y registers.
|
||||||
|
%asm {{
|
||||||
|
sta cleanup_at_exit._exitcode
|
||||||
|
stx cleanup_at_exit._exitcodeX
|
||||||
|
sty cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub exit3(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y, bool carry @Pc) {
|
||||||
|
; -- immediately exit the program with result values in the A, X and Y registers, and the Carry flag in the status register.
|
||||||
|
%asm {{
|
||||||
|
sta cleanup_at_exit._exitcode
|
||||||
|
lda #0
|
||||||
|
rol a
|
||||||
|
sta cleanup_at_exit._exitcodeCarry
|
||||||
|
stx cleanup_at_exit._exitcodeX
|
||||||
|
sty cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
inline asmsub progend() -> uword @AY {
|
inline asmsub progend() -> uword @AY {
|
||||||
%asm {{
|
%asm {{
|
||||||
lda #<prog8_program_end
|
lda #<prog8_program_end
|
||||||
|
@ -110,8 +110,15 @@ asmsub init_system_phase2() {
|
|||||||
asmsub cleanup_at_exit() {
|
asmsub cleanup_at_exit() {
|
||||||
; executed when the main subroutine does rts
|
; executed when the main subroutine does rts
|
||||||
%asm {{
|
%asm {{
|
||||||
|
_exitcodeCarry = *+1
|
||||||
|
lda #0
|
||||||
|
lsr a
|
||||||
_exitcode = *+1
|
_exitcode = *+1
|
||||||
lda #0 ; exit code possibly modified in exit()
|
lda #0 ; exit code possibly modified in exit()
|
||||||
|
_exitcodeX = *+1
|
||||||
|
ldx #0
|
||||||
|
_exitcodeY = *+1
|
||||||
|
ldy #0
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -351,6 +358,33 @@ save_SCRATCH_ZPWORD2 .word 0
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub exit2(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y) {
|
||||||
|
; -- immediately exit the program with result values in the A, X and Y registers.
|
||||||
|
%asm {{
|
||||||
|
sta cleanup_at_exit._exitcode
|
||||||
|
stx cleanup_at_exit._exitcodeX
|
||||||
|
sty cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
asmsub exit3(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y, bool carry @Pc) {
|
||||||
|
; -- immediately exit the program with result values in the A, X and Y registers, and the Carry flag in the status register.
|
||||||
|
%asm {{
|
||||||
|
sta cleanup_at_exit._exitcode
|
||||||
|
lda #0
|
||||||
|
rol a
|
||||||
|
sta cleanup_at_exit._exitcodeCarry
|
||||||
|
stx cleanup_at_exit._exitcodeX
|
||||||
|
sty cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
inline asmsub progend() -> uword @AY {
|
inline asmsub progend() -> uword @AY {
|
||||||
%asm {{
|
%asm {{
|
||||||
lda #<prog8_program_end
|
lda #<prog8_program_end
|
||||||
|
@ -58,6 +58,14 @@ sys (part of syslib)
|
|||||||
Immediately stops the program and exits it, with the returncode in the A register.
|
Immediately stops the program and exits it, with the returncode in the A register.
|
||||||
Note: custom interrupt handlers remain active unless manually cleared first!
|
Note: custom interrupt handlers remain active unless manually cleared first!
|
||||||
|
|
||||||
|
``exit2 (resultA, resultX, resultY)``
|
||||||
|
Immediately stops the program and exits it, with the result values in the A, X and Y registers.
|
||||||
|
Note: custom interrupt handlers remain active unless manually cleared first!
|
||||||
|
|
||||||
|
``exit3 (resultA, resultX, resultY, carry)``
|
||||||
|
Immediately stops the program and exits it, with the result values in the A, X and Y registers, and the carry flag in the status register.
|
||||||
|
Note: custom interrupt handlers remain active unless manually cleared first!
|
||||||
|
|
||||||
``memcopy (from, to, numbytes)``
|
``memcopy (from, to, numbytes)``
|
||||||
Efficiently copy a number of bytes from a memory location to another.
|
Efficiently copy a number of bytes from a memory location to another.
|
||||||
*Warning:* can only copy *non-overlapping* memory areas correctly!
|
*Warning:* can only copy *non-overlapping* memory areas correctly!
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
add a zsmkit example (next to zsound example)
|
|
||||||
|
|
||||||
fix compiler crash for for cx16.r9L in conv.str_ub(number) {...} : can't iterate over class prog8.code.ast.PtFunctionCall - should have been replaced by a variable
|
|
||||||
|
|
||||||
...
|
...
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
;; Proof Of Concept Zsound player using a binary blob version of zsound library by ZeroByte relocated to something usable here.
|
;; Proof Of Concept Zsound player using a binary blob version of zsound library by ZeroByte relocated to something usable here.
|
||||||
;; Can play ZSM (music) and ZCM (pcm samples).
|
;; Can play ZSM (music) and ZCM (pcm samples).
|
||||||
|
|
||||||
|
; NOTE: the ZSound library is DEPRECATED and ZSMKIT is its successor.
|
||||||
|
; find prog8 examples with ZSMKIT here: https://github.com/mooinglemur/zsmkit/tree/main/p8demo
|
||||||
|
|
||||||
; "issues":
|
; "issues":
|
||||||
; - prog8 (or rather, 64tass) cannot "link" other assembly object files so we have to incbin a binary blob.
|
; - prog8 (or rather, 64tass) cannot "link" other assembly object files so we have to incbin a binary blob.
|
||||||
; - zsound player ZP usage is only known after compilation of zsound lib. And then this has to be blocked off in the prog8 program.
|
; - zsound player ZP usage is only known after compilation of zsound lib. And then this has to be blocked off in the prog8 program.
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
%import diskio
|
%import diskio
|
||||||
%zpreserved $22,$2d ; zsound lib uses this region
|
%zpreserved $22,$2d ; zsound lib uses this region
|
||||||
|
|
||||||
|
; NOTE: the ZSound library is DEPRECATED and ZSMKIT is its successor.
|
||||||
|
; find prog8 examples with ZSMKIT here: https://github.com/mooinglemur/zsmkit/tree/main/p8demo
|
||||||
|
|
||||||
; NOTE: this is a proof of concept to stream ZCM digi from disk while playing.
|
; NOTE: this is a proof of concept to stream ZCM digi from disk while playing.
|
||||||
; currently there's no real streaming API / circular buffer in zsound,
|
; currently there's no real streaming API / circular buffer in zsound,
|
||||||
; so it simply loads the whole ZCM file in chunks in memory sequentially.
|
; so it simply loads the whole ZCM file in chunks in memory sequentially.
|
||||||
|
@ -1,27 +1,10 @@
|
|||||||
%import math
|
%zeropage basicsafe
|
||||||
%import monogfx
|
%option no_sysinit
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
monogfx.hires()
|
;sys.exit(99)
|
||||||
monogfx.drawmode(monogfx.MODE_INVERT)
|
;sys.exit2(99,123,200)
|
||||||
|
sys.exit3(99,123,200,true)
|
||||||
ubyte tt
|
|
||||||
|
|
||||||
repeat {
|
|
||||||
ubyte tts=tt
|
|
||||||
word x1 = math.sin8(tts)
|
|
||||||
word y1 = math.cos8(tts)
|
|
||||||
tts += 256/3
|
|
||||||
word x2 = math.sin8(tts)
|
|
||||||
word y2 = math.cos8(tts)
|
|
||||||
tts += 256/3
|
|
||||||
word x3 = math.sin8(tts)
|
|
||||||
word y3 = math.cos8(tts)
|
|
||||||
monogfx.line(320+x1*2 as uword, 240+y1 as uword, 320+x2 as uword, 240+y2 as uword, true)
|
|
||||||
monogfx.line(320+x2*2 as uword, 240+y2 as uword, 320+x3 as uword, 240+y3 as uword, true)
|
|
||||||
monogfx.line(320+x3*2 as uword, 240+y3 as uword, 320+x1 as uword, 240+y1 as uword, true)
|
|
||||||
tt++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user