mirror of
https://github.com/irmen/prog8.git
synced 2025-10-25 22:17:23 +00:00
sys.exit(), exit2(), exit3() now romable
This commit is contained in:
@@ -445,7 +445,6 @@ sys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
asmsub save_prog8_internals() {
|
asmsub save_prog8_internals() {
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
lda P8ZP_SCRATCH_B1
|
lda P8ZP_SCRATCH_B1
|
||||||
sta save_SCRATCH_ZPB1
|
sta save_SCRATCH_ZPB1
|
||||||
@@ -896,7 +895,7 @@ _no_msb_size
|
|||||||
sta p8_sys_startup.cleanup_at_exit._exitcode
|
sta p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
lda #0
|
lda #0
|
||||||
rol a
|
rol a
|
||||||
sta p8_sys_startup.cleanup_at_exit._exitcodeCarry
|
sta p8_sys_startup.cleanup_at_exit._exitcarry
|
||||||
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
||||||
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
||||||
ldx prog8_lib.orig_stackpointer
|
ldx prog8_lib.orig_stackpointer
|
||||||
@@ -1071,7 +1070,6 @@ cx16 {
|
|||||||
&byte r15sH = $1bff
|
&byte r15sH = $1bff
|
||||||
|
|
||||||
asmsub save_virtual_registers() clobbers(A,Y) {
|
asmsub save_virtual_registers() clobbers(A,Y) {
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
ldy #31
|
ldy #31
|
||||||
- lda cx16.r0,y
|
- lda cx16.r0,y
|
||||||
@@ -1148,22 +1146,26 @@ 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
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
lda #0
|
lda #0
|
||||||
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 _exitcarry
|
||||||
lda #0
|
|
||||||
lsr a
|
lsr a
|
||||||
_exitcode = *+1
|
lda _exitcode
|
||||||
lda #0 ; exit code possibly modified in exit()
|
ldx _exitcodeX
|
||||||
_exitcodeX = *+1
|
ldy _exitcodeY
|
||||||
ldx #0
|
|
||||||
_exitcodeY = *+1
|
|
||||||
ldy #0
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.section BSS
|
||||||
|
_exitcarry .byte ?
|
||||||
|
_exitcode .byte ?
|
||||||
|
_exitcodeX .byte ?
|
||||||
|
_exitcodeY .byte ?
|
||||||
|
.send BSS
|
||||||
|
|
||||||
|
; !notreached!
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -461,7 +461,6 @@ sys {
|
|||||||
}
|
}
|
||||||
|
|
||||||
asmsub save_prog8_internals() {
|
asmsub save_prog8_internals() {
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
lda P8ZP_SCRATCH_B1
|
lda P8ZP_SCRATCH_B1
|
||||||
sta save_SCRATCH_ZPB1
|
sta save_SCRATCH_ZPB1
|
||||||
@@ -914,7 +913,7 @@ _no_msb_size
|
|||||||
sta p8_sys_startup.cleanup_at_exit._exitcode
|
sta p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
lda #0
|
lda #0
|
||||||
rol a
|
rol a
|
||||||
sta p8_sys_startup.cleanup_at_exit._exitcodeCarry
|
sta p8_sys_startup.cleanup_at_exit._exitcarry
|
||||||
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
||||||
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
||||||
ldx prog8_lib.orig_stackpointer
|
ldx prog8_lib.orig_stackpointer
|
||||||
@@ -1089,7 +1088,6 @@ cx16 {
|
|||||||
&byte r15sH = $cfff
|
&byte r15sH = $cfff
|
||||||
|
|
||||||
asmsub save_virtual_registers() clobbers(A,Y) {
|
asmsub save_virtual_registers() clobbers(A,Y) {
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
ldy #31
|
ldy #31
|
||||||
- lda cx16.r0,y
|
- lda cx16.r0,y
|
||||||
@@ -1177,7 +1175,6 @@ 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
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
lda #%00101111
|
lda #%00101111
|
||||||
sta $00
|
sta $00
|
||||||
@@ -1189,16 +1186,21 @@ asmsub cleanup_at_exit() {
|
|||||||
jsr cbm.MEMTOP ; adjust MEMTOP down again
|
jsr cbm.MEMTOP ; adjust MEMTOP down again
|
||||||
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 _exitcarry
|
||||||
lda #0
|
|
||||||
lsr a
|
lsr a
|
||||||
_exitcode = *+1
|
lda _exitcode
|
||||||
lda #0 ; exit code possibly modified in exit()
|
ldx _exitcodeX
|
||||||
_exitcodeX = *+1
|
ldy _exitcodeY
|
||||||
ldx #0
|
|
||||||
_exitcodeY = *+1
|
|
||||||
ldy #0
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.section BSS
|
||||||
|
_exitcarry .byte ?
|
||||||
|
_exitcode .byte ?
|
||||||
|
_exitcodeX .byte ?
|
||||||
|
_exitcodeY .byte ?
|
||||||
|
.send BSS
|
||||||
|
|
||||||
|
; !notreached!
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -352,7 +352,6 @@ asmsub str2word(str string @AY) -> word @AY {
|
|||||||
; the number may be preceded by a + or - sign but may NOT contain spaces
|
; the number may be preceded by a + or - sign but may NOT contain spaces
|
||||||
; (any non-digit character will terminate the number string that is parsed)
|
; (any non-digit character will terminate the number string that is parsed)
|
||||||
; result in AY, number of characters processed also remains in cx16.r15 if you want to use it!! (0 = error)
|
; result in AY, number of characters processed also remains in cx16.r15 if you want to use it!! (0 = error)
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
_result = P8ZP_SCRATCH_W1
|
_result = P8ZP_SCRATCH_W1
|
||||||
sta P8ZP_SCRATCH_W2
|
sta P8ZP_SCRATCH_W2
|
||||||
@@ -542,7 +541,6 @@ asmsub internal_uword2decimal (uword value @AY) -> ubyte @Y, ubyte @A, ubyte @
|
|||||||
; output in internal_uword2decimal.decTenThousands, decThousands, decHundreds, decTens, decOnes
|
; output in internal_uword2decimal.decTenThousands, decThousands, decHundreds, decTens, decOnes
|
||||||
; (these are terminated by a zero byte so they can be easily printed)
|
; (these are terminated by a zero byte so they can be easily printed)
|
||||||
; also returns Y = 100's, A = 10's, X = 1's
|
; also returns Y = 100's, A = 10's, X = 1's
|
||||||
; TODO: Romable
|
|
||||||
|
|
||||||
%asm {{
|
%asm {{
|
||||||
|
|
||||||
|
|||||||
@@ -1046,7 +1046,6 @@ asmsub vpoke_mask(ubyte bank @A, uword address @R0, ubyte mask @X, ubyte value @
|
|||||||
}
|
}
|
||||||
|
|
||||||
asmsub save_virtual_registers() clobbers(A,Y) {
|
asmsub save_virtual_registers() clobbers(A,Y) {
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
ldy #31
|
ldy #31
|
||||||
- lda cx16.r0,y
|
- lda cx16.r0,y
|
||||||
@@ -1077,7 +1076,6 @@ asmsub restore_virtual_registers() clobbers(A,Y) {
|
|||||||
|
|
||||||
asmsub save_vera_context() clobbers(A) {
|
asmsub save_vera_context() clobbers(A) {
|
||||||
; -- use this at the start of your IRQ handler if it uses Vera registers, to save the state
|
; -- use this at the start of your IRQ handler if it uses Vera registers, to save the state
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
; note cannot store this on cpu hardware stack because this gets called as a subroutine
|
; note cannot store this on cpu hardware stack because this gets called as a subroutine
|
||||||
lda cx16.VERA_ADDR_L
|
lda cx16.VERA_ADDR_L
|
||||||
@@ -1526,7 +1524,6 @@ _vector .word ?
|
|||||||
}
|
}
|
||||||
|
|
||||||
asmsub restore_irq() clobbers(A) {
|
asmsub restore_irq() clobbers(A) {
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
sei
|
sei
|
||||||
lda _orig_irqvec
|
lda _orig_irqvec
|
||||||
@@ -1863,7 +1860,6 @@ _no_msb_size
|
|||||||
}
|
}
|
||||||
|
|
||||||
asmsub save_prog8_internals() {
|
asmsub save_prog8_internals() {
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
lda P8ZP_SCRATCH_B1
|
lda P8ZP_SCRATCH_B1
|
||||||
sta save_SCRATCH_ZPB1
|
sta save_SCRATCH_ZPB1
|
||||||
@@ -1934,7 +1930,7 @@ save_SCRATCH_ZPWORD2 .word ?
|
|||||||
sta p8_sys_startup.cleanup_at_exit._exitcode
|
sta p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
lda #0
|
lda #0
|
||||||
rol a
|
rol a
|
||||||
sta p8_sys_startup.cleanup_at_exit._exitcodeCarry
|
sta p8_sys_startup.cleanup_at_exit._exitcarry
|
||||||
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
||||||
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
||||||
ldx prog8_lib.orig_stackpointer
|
ldx prog8_lib.orig_stackpointer
|
||||||
@@ -2064,7 +2060,6 @@ 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
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
lda #1
|
lda #1
|
||||||
sta $00 ; ram bank 1
|
sta $00 ; ram bank 1
|
||||||
@@ -2073,16 +2068,21 @@ asmsub cleanup_at_exit() {
|
|||||||
jsr cbm.CLRCHN ; reset i/o channels
|
jsr cbm.CLRCHN ; reset i/o channels
|
||||||
lda #9
|
lda #9
|
||||||
jsr cbm.CHROUT ; enable charset switch
|
jsr cbm.CHROUT ; enable charset switch
|
||||||
_exitcodeCarry = *+1
|
lda _exitcarry
|
||||||
lda #0
|
|
||||||
lsr a
|
lsr a
|
||||||
_exitcode = *+1
|
lda _exitcode
|
||||||
lda #0 ; exit code possibly modified in exit()
|
ldx _exitcodeX
|
||||||
_exitcodeX = *+1
|
ldy _exitcodeY
|
||||||
ldx #0
|
|
||||||
_exitcodeY = *+1
|
|
||||||
ldy #0
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.section BSS
|
||||||
|
_exitcarry .byte ?
|
||||||
|
_exitcode .byte ?
|
||||||
|
_exitcodeX .byte ?
|
||||||
|
_exitcodeY .byte ?
|
||||||
|
.send BSS
|
||||||
|
|
||||||
|
; !notreached!
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -360,7 +360,6 @@ _no_msb_size
|
|||||||
}
|
}
|
||||||
|
|
||||||
asmsub save_prog8_internals() {
|
asmsub save_prog8_internals() {
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
lda P8ZP_SCRATCH_B1
|
lda P8ZP_SCRATCH_B1
|
||||||
sta save_SCRATCH_ZPB1
|
sta save_SCRATCH_ZPB1
|
||||||
@@ -431,7 +430,7 @@ save_SCRATCH_ZPWORD2 .word ?
|
|||||||
sta p8_sys_startup.cleanup_at_exit._exitcode
|
sta p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
lda #0
|
lda #0
|
||||||
rol a
|
rol a
|
||||||
sta p8_sys_startup.cleanup_at_exit._exitcodeCarry
|
sta p8_sys_startup.cleanup_at_exit._exitcarry
|
||||||
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
||||||
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
||||||
ldx prog8_lib.orig_stackpointer
|
ldx prog8_lib.orig_stackpointer
|
||||||
@@ -606,7 +605,6 @@ cx16 {
|
|||||||
&byte r15sH = $7fff
|
&byte r15sH = $7fff
|
||||||
|
|
||||||
asmsub save_virtual_registers() clobbers(A,Y) {
|
asmsub save_virtual_registers() clobbers(A,Y) {
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
ldy #31
|
ldy #31
|
||||||
- lda cx16.r0,y
|
- lda cx16.r0,y
|
||||||
@@ -671,18 +669,22 @@ 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
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
_exitcodeCarry = *+1
|
lda _exitcarry
|
||||||
lda #0
|
|
||||||
lsr a
|
lsr a
|
||||||
_exitcode = *+1
|
lda _exitcode
|
||||||
lda #0 ; exit code possibly modified in exit()
|
ldx _exitcodeX
|
||||||
_exitcodeX = *+1
|
ldy _exitcodeY
|
||||||
ldx #0
|
|
||||||
_exitcodeY = *+1
|
|
||||||
ldy #0
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.section BSS
|
||||||
|
_exitcarry .byte ?
|
||||||
|
_exitcode .byte ?
|
||||||
|
_exitcodeX .byte ?
|
||||||
|
_exitcodeY .byte ?
|
||||||
|
.send BSS
|
||||||
|
|
||||||
|
; !notreached!
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ save_SCRATCH_ZPWORD2 .word 0
|
|||||||
sta p8_sys_startup.cleanup_at_exit._exitcode
|
sta p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
lda #0
|
lda #0
|
||||||
rol a
|
rol a
|
||||||
sta p8_sys_startup.cleanup_at_exit._exitcodeCarry
|
sta p8_sys_startup.cleanup_at_exit._exitcarry
|
||||||
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
||||||
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
||||||
ldx prog8_lib.orig_stackpointer
|
ldx prog8_lib.orig_stackpointer
|
||||||
@@ -563,18 +563,22 @@ p8_sys_startup {
|
|||||||
|
|
||||||
asmsub cleanup_at_exit() {
|
asmsub cleanup_at_exit() {
|
||||||
; executed when the main subroutine does rts
|
; executed when the main subroutine does rts
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
_exitcodeCarry = *+1
|
lda _exitcarry
|
||||||
lda #0
|
|
||||||
lsr a
|
lsr a
|
||||||
_exitcode = *+1
|
lda _exitcode
|
||||||
lda #0 ; exit code possibly modified in exit()
|
ldx _exitcodeX
|
||||||
_exitcodeX = *+1
|
ldy _exitcodeY
|
||||||
ldx #0
|
|
||||||
_exitcodeY = *+1
|
|
||||||
ldy #0
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.section BSS
|
||||||
|
_exitcarry .byte ?
|
||||||
|
_exitcode .byte ?
|
||||||
|
_exitcodeX .byte ?
|
||||||
|
_exitcodeY .byte ?
|
||||||
|
.send BSS
|
||||||
|
|
||||||
|
; !notreached!
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,37 +238,37 @@ save_SCRATCH_ZPWORD2 .word 0
|
|||||||
asmsub exit(ubyte returnvalue @A) {
|
asmsub exit(ubyte returnvalue @A) {
|
||||||
; -- immediately exit the program with a return code in the A register
|
; -- immediately exit the program with a return code in the A register
|
||||||
%asm {{
|
%asm {{
|
||||||
sta cleanup_at_exit._exitcode
|
sta p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
ldx prog8_lib.orig_stackpointer
|
ldx prog8_lib.orig_stackpointer
|
||||||
txs
|
txs
|
||||||
jmp cleanup_at_exit
|
jmp p8_sys_startup.cleanup_at_exit
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub exit2(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y) {
|
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.
|
; -- immediately exit the program with result values in the A, X and Y registers.
|
||||||
%asm {{
|
%asm {{
|
||||||
sta cleanup_at_exit._exitcode
|
sta p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
stx cleanup_at_exit._exitcodeX
|
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
||||||
sty cleanup_at_exit._exitcodeY
|
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
||||||
ldx prog8_lib.orig_stackpointer
|
ldx prog8_lib.orig_stackpointer
|
||||||
txs
|
txs
|
||||||
jmp cleanup_at_exit
|
jmp p8_sys_startup.cleanup_at_exit
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
asmsub exit3(ubyte resulta @A, ubyte resultx @X, ubyte resulty @Y, bool carry @Pc) {
|
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.
|
; -- immediately exit the program with result values in the A, X and Y registers, and the Carry flag in the status register.
|
||||||
%asm {{
|
%asm {{
|
||||||
sta cleanup_at_exit._exitcode
|
sta p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
lda #0
|
lda #0
|
||||||
rol a
|
rol a
|
||||||
sta cleanup_at_exit._exitcodeCarry
|
sta p8_sys_startup.cleanup_at_exit._exitcarry
|
||||||
stx cleanup_at_exit._exitcodeX
|
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
||||||
sty cleanup_at_exit._exitcodeY
|
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
||||||
ldx prog8_lib.orig_stackpointer
|
ldx prog8_lib.orig_stackpointer
|
||||||
txs
|
txs
|
||||||
jmp cleanup_at_exit
|
jmp p8_sys_startup.cleanup_at_exit
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,18 +493,22 @@ p8_sys_startup {
|
|||||||
|
|
||||||
asmsub cleanup_at_exit() {
|
asmsub cleanup_at_exit() {
|
||||||
; executed when the main subroutine does rts
|
; executed when the main subroutine does rts
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
_exitcodeCarry = *+1
|
lda _exitcarry
|
||||||
lda #0
|
|
||||||
lsr a
|
lsr a
|
||||||
_exitcode = *+1
|
lda _exitcode
|
||||||
lda #0 ; exit code possibly modified in exit()
|
ldx _exitcodeX
|
||||||
_exitcodeX = *+1
|
ldy _exitcodeY
|
||||||
ldx #0
|
|
||||||
_exitcodeY = *+1
|
|
||||||
ldy #0
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.section BSS
|
||||||
|
_exitcarry .byte ?
|
||||||
|
_exitcode .byte ?
|
||||||
|
_exitcodeX .byte ?
|
||||||
|
_exitcodeY .byte ?
|
||||||
|
.send BSS
|
||||||
|
|
||||||
|
; !notreached!
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,20 @@ sys {
|
|||||||
|
|
||||||
; these push/pop routines are always required by the compiler:
|
; these push/pop routines are always required by the compiler:
|
||||||
|
|
||||||
|
inline asmsub progend() -> uword @AY {
|
||||||
|
%asm {{
|
||||||
|
lda #<prog8_program_end
|
||||||
|
ldy #>prog8_program_end
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline asmsub progstart() -> uword @AY {
|
||||||
|
%asm {{
|
||||||
|
lda #<prog8_program_start
|
||||||
|
ldy #>prog8_program_start
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
inline asmsub push(ubyte value @A) {
|
inline asmsub push(ubyte value @A) {
|
||||||
%asm {{
|
%asm {{
|
||||||
pha
|
pha
|
||||||
@@ -44,6 +58,43 @@ sys {
|
|||||||
jmp ($fffc) ; reset vector
|
jmp ($fffc) ; reset vector
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub exit(ubyte returnvalue @A) {
|
||||||
|
; -- immediately exit the program with a return code in the A register
|
||||||
|
%asm {{
|
||||||
|
sta p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp p8_sys_startup.cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
|
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
||||||
|
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp p8_sys_startup.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 p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
|
lda #0
|
||||||
|
rol a
|
||||||
|
sta p8_sys_startup.cleanup_at_exit._exitcarry
|
||||||
|
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
||||||
|
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp p8_sys_startup.cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -64,18 +115,22 @@ p8_sys_startup {
|
|||||||
|
|
||||||
asmsub cleanup_at_exit() {
|
asmsub cleanup_at_exit() {
|
||||||
; executed when the main subroutine does rts
|
; executed when the main subroutine does rts
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
_exitcodeCarry = *+1
|
lda _exitcarry
|
||||||
lda #0
|
|
||||||
lsr a
|
lsr a
|
||||||
_exitcode = *+1
|
lda _exitcode
|
||||||
lda #0 ; exit code possibly modified in exit()
|
ldx _exitcodeX
|
||||||
_exitcodeX = *+1
|
ldy _exitcodeY
|
||||||
ldx #0
|
|
||||||
_exitcodeY = *+1
|
|
||||||
ldy #0
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.section BSS
|
||||||
|
_exitcarry .byte ?
|
||||||
|
_exitcode .byte ?
|
||||||
|
_exitcodeX .byte ?
|
||||||
|
_exitcodeY .byte ?
|
||||||
|
.send BSS
|
||||||
|
|
||||||
|
; !notreached!
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,20 @@ sys {
|
|||||||
|
|
||||||
; these push/pop routines are always required by the compiler:
|
; these push/pop routines are always required by the compiler:
|
||||||
|
|
||||||
|
inline asmsub progend() -> uword @AY {
|
||||||
|
%asm {{
|
||||||
|
lda #<prog8_program_end
|
||||||
|
ldy #>prog8_program_end
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline asmsub progstart() -> uword @AY {
|
||||||
|
%asm {{
|
||||||
|
lda #<prog8_program_start
|
||||||
|
ldy #>prog8_program_start
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
inline asmsub push(ubyte value @A) {
|
inline asmsub push(ubyte value @A) {
|
||||||
%asm {{
|
%asm {{
|
||||||
pha
|
pha
|
||||||
@@ -48,6 +62,42 @@ sys {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub exit(ubyte returnvalue @A) {
|
||||||
|
; -- immediately exit the program with a return code in the A register
|
||||||
|
%asm {{
|
||||||
|
sta p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp p8_sys_startup.cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
|
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
||||||
|
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp p8_sys_startup.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 p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
|
lda #0
|
||||||
|
rol a
|
||||||
|
sta p8_sys_startup.cleanup_at_exit._exitcarry
|
||||||
|
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
||||||
|
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp p8_sys_startup.cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -68,18 +118,23 @@ p8_sys_startup {
|
|||||||
|
|
||||||
asmsub cleanup_at_exit() {
|
asmsub cleanup_at_exit() {
|
||||||
; executed when the main subroutine does rts
|
; executed when the main subroutine does rts
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
_exitcodeCarry = *+1
|
lda _exitcarry
|
||||||
lda #0
|
|
||||||
lsr a
|
lsr a
|
||||||
_exitcode = *+1
|
lda _exitcode
|
||||||
lda #0 ; exit code possibly modified in exit()
|
ldx _exitcodeX
|
||||||
_exitcodeX = *+1
|
ldy _exitcodeY
|
||||||
ldx #0
|
|
||||||
_exitcodeY = *+1
|
|
||||||
ldy #0
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.section BSS
|
||||||
|
_exitcarry .byte ?
|
||||||
|
_exitcode .byte ?
|
||||||
|
_exitcodeX .byte ?
|
||||||
|
_exitcodeY .byte ?
|
||||||
|
.send BSS
|
||||||
|
|
||||||
|
; !notreached!
|
||||||
|
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,20 @@ sys {
|
|||||||
|
|
||||||
; these push/pop routines are always required by the compiler:
|
; these push/pop routines are always required by the compiler:
|
||||||
|
|
||||||
|
inline asmsub progend() -> uword @AY {
|
||||||
|
%asm {{
|
||||||
|
lda #<prog8_program_end
|
||||||
|
ldy #>prog8_program_end
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline asmsub progstart() -> uword @AY {
|
||||||
|
%asm {{
|
||||||
|
lda #<prog8_program_start
|
||||||
|
ldy #>prog8_program_start
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
inline asmsub push(ubyte value @A) {
|
inline asmsub push(ubyte value @A) {
|
||||||
%asm {{
|
%asm {{
|
||||||
pha
|
pha
|
||||||
@@ -42,6 +56,43 @@ sys {
|
|||||||
jmp ($fffc) ; reset vector
|
jmp ($fffc) ; reset vector
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub exit(ubyte returnvalue @A) {
|
||||||
|
; -- immediately exit the program with a return code in the A register
|
||||||
|
%asm {{
|
||||||
|
sta p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp p8_sys_startup.cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
|
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 p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
|
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
||||||
|
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp p8_sys_startup.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 p8_sys_startup.cleanup_at_exit._exitcode
|
||||||
|
lda #0
|
||||||
|
rol a
|
||||||
|
sta p8_sys_startup.cleanup_at_exit._exitcarry
|
||||||
|
stx p8_sys_startup.cleanup_at_exit._exitcodeX
|
||||||
|
sty p8_sys_startup.cleanup_at_exit._exitcodeY
|
||||||
|
ldx prog8_lib.orig_stackpointer
|
||||||
|
txs
|
||||||
|
jmp p8_sys_startup.cleanup_at_exit
|
||||||
|
}}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -62,18 +113,22 @@ p8_sys_startup {
|
|||||||
|
|
||||||
asmsub cleanup_at_exit() {
|
asmsub cleanup_at_exit() {
|
||||||
; executed when the main subroutine does rts
|
; executed when the main subroutine does rts
|
||||||
; TODO: Romable
|
|
||||||
%asm {{
|
%asm {{
|
||||||
_exitcodeCarry = *+1
|
lda _exitcarry
|
||||||
lda #0
|
|
||||||
lsr a
|
lsr a
|
||||||
_exitcode = *+1
|
lda _exitcode
|
||||||
lda #0 ; exit code possibly modified in exit()
|
ldx _exitcodeX
|
||||||
_exitcodeX = *+1
|
ldy _exitcodeY
|
||||||
ldx #0
|
|
||||||
_exitcodeY = *+1
|
|
||||||
ldy #0
|
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
.section BSS
|
||||||
|
_exitcarry .byte ?
|
||||||
|
_exitcode .byte ?
|
||||||
|
_exitcodeX .byte ?
|
||||||
|
_exitcodeY .byte ?
|
||||||
|
.send BSS
|
||||||
|
|
||||||
|
; !notreached!
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,8 @@
|
|||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
str name = "irmen!"
|
sys.exit3(100,101,102,true)
|
||||||
txt.print(name)
|
sys.exit2(100,101,102)
|
||||||
txt.nl()
|
sys.exit(100)
|
||||||
sys.memset(&name, len(name), 'a')
|
|
||||||
txt.print(name)
|
|
||||||
txt.nl()
|
|
||||||
sys.memsetw(&name, len(name)/2, $4041)
|
|
||||||
txt.print(name)
|
|
||||||
txt.nl()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user