mirror of
				https://github.com/irmen/prog8.git
				synced 2025-10-31 15:16:13 +00:00 
			
		
		
		
	sys.exit(), exit2(), exit3() now romable
This commit is contained in:
		| @@ -445,7 +445,6 @@ sys { | ||||
|     } | ||||
|  | ||||
|     asmsub save_prog8_internals() { | ||||
|         ; TODO: Romable | ||||
|         %asm {{ | ||||
|             lda  P8ZP_SCRATCH_B1 | ||||
|             sta  save_SCRATCH_ZPB1 | ||||
| @@ -896,7 +895,7 @@ _no_msb_size | ||||
|             sta  p8_sys_startup.cleanup_at_exit._exitcode | ||||
|             lda  #0 | ||||
|             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 | ||||
|             sty  p8_sys_startup.cleanup_at_exit._exitcodeY | ||||
|             ldx  prog8_lib.orig_stackpointer | ||||
| @@ -1071,7 +1070,6 @@ cx16 { | ||||
|     &byte r15sH = $1bff | ||||
|  | ||||
|     asmsub save_virtual_registers() clobbers(A,Y) { | ||||
| 		; TODO: Romable | ||||
|         %asm {{ | ||||
|             ldy  #31 | ||||
|     -       lda  cx16.r0,y | ||||
| @@ -1148,22 +1146,26 @@ asmsub  init_system_phase2()  { | ||||
|  | ||||
| asmsub  cleanup_at_exit() { | ||||
|     ; executed when the main subroutine does rts | ||||
|     ; TODO: Romable | ||||
|     %asm {{ | ||||
|         lda  #0 | ||||
|         sta  $ff00          ; default bank 15 | ||||
|         jsr  cbm.CLRCHN		; reset i/o channels | ||||
|         jsr  enable_runstop_and_charsetswitch | ||||
| _exitcodeCarry = *+1 | ||||
|         lda  #0 | ||||
|         lda  _exitcarry | ||||
|         lsr  a | ||||
| _exitcode = *+1 | ||||
|         lda  #0        ; exit code possibly modified in exit() | ||||
| _exitcodeX = *+1 | ||||
|         ldx  #0 | ||||
| _exitcodeY = *+1 | ||||
|         ldy  #0 | ||||
|         lda  _exitcode | ||||
|         ldx  _exitcodeX | ||||
|         ldy  _exitcodeY | ||||
|         rts | ||||
|  | ||||
|         .section BSS | ||||
| _exitcarry  .byte ? | ||||
| _exitcode   .byte ? | ||||
| _exitcodeX  .byte ? | ||||
| _exitcodeY  .byte ? | ||||
|         .send BSS | ||||
|  | ||||
|         ; !notreached! | ||||
|     }} | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -461,7 +461,6 @@ sys { | ||||
|     } | ||||
|  | ||||
|     asmsub save_prog8_internals() { | ||||
|         ; TODO: Romable | ||||
|         %asm {{ | ||||
|             lda  P8ZP_SCRATCH_B1 | ||||
|             sta  save_SCRATCH_ZPB1 | ||||
| @@ -914,7 +913,7 @@ _no_msb_size | ||||
|             sta  p8_sys_startup.cleanup_at_exit._exitcode | ||||
|             lda  #0 | ||||
|             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 | ||||
|             sty  p8_sys_startup.cleanup_at_exit._exitcodeY | ||||
|             ldx  prog8_lib.orig_stackpointer | ||||
| @@ -1089,7 +1088,6 @@ cx16 { | ||||
|     &byte r15sH = $cfff | ||||
|  | ||||
|     asmsub save_virtual_registers() clobbers(A,Y) { | ||||
| 		; TODO: Romable | ||||
|         %asm {{ | ||||
|             ldy  #31 | ||||
|     -       lda  cx16.r0,y | ||||
| @@ -1177,7 +1175,6 @@ asmsub  init_system_phase2()  { | ||||
|  | ||||
| asmsub  cleanup_at_exit() { | ||||
|     ; executed when the main subroutine does rts | ||||
|     ; TODO: Romable | ||||
|     %asm {{ | ||||
|         lda  #%00101111 | ||||
|         sta  $00 | ||||
| @@ -1189,16 +1186,21 @@ asmsub  cleanup_at_exit() { | ||||
|         jsr  cbm.MEMTOP     ; adjust MEMTOP down again | ||||
|         jsr  cbm.CLRCHN		; reset i/o channels | ||||
|         jsr  enable_runstop_and_charsetswitch | ||||
| _exitcodeCarry = *+1 | ||||
|         lda  #0 | ||||
|         lda  _exitcarry | ||||
|         lsr  a | ||||
| _exitcode = *+1 | ||||
|         lda  #0        ; exit code possibly modified in exit() | ||||
| _exitcodeX = *+1 | ||||
|         ldx  #0 | ||||
| _exitcodeY = *+1 | ||||
|         ldy  #0 | ||||
|         lda  _exitcode | ||||
|         ldx  _exitcodeX | ||||
|         ldy  _exitcodeY | ||||
|         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 | ||||
| 	;    (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) | ||||
|     ; TODO: Romable | ||||
| 	%asm {{ | ||||
| _result = P8ZP_SCRATCH_W1 | ||||
| 		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 | ||||
| 	;  (these are terminated by a zero byte so they can be easily printed) | ||||
| 	;  also returns Y = 100's, A = 10's, X = 1's | ||||
|     ; TODO: Romable | ||||
|  | ||||
| 	%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) { | ||||
|     ; TODO: Romable | ||||
|     %asm {{ | ||||
|         ldy  #31 | ||||
| -       lda  cx16.r0,y | ||||
| @@ -1077,7 +1076,6 @@ asmsub restore_virtual_registers() clobbers(A,Y) { | ||||
|  | ||||
| asmsub save_vera_context() clobbers(A) { | ||||
|     ; -- use this at the start of your IRQ handler if it uses Vera registers, to save the state | ||||
|     ; TODO: Romable | ||||
|     %asm {{ | ||||
|         ; note cannot store this on cpu hardware stack because this gets called as a subroutine | ||||
|         lda  cx16.VERA_ADDR_L | ||||
| @@ -1526,7 +1524,6 @@ _vector	.word ? | ||||
| } | ||||
|  | ||||
| asmsub  restore_irq() clobbers(A) { | ||||
|     ; TODO: Romable | ||||
| 	%asm {{ | ||||
| 	    sei | ||||
| 	    lda  _orig_irqvec | ||||
| @@ -1863,7 +1860,6 @@ _no_msb_size | ||||
|     } | ||||
|  | ||||
|     asmsub save_prog8_internals() { | ||||
|         ; TODO: Romable | ||||
|         %asm {{ | ||||
|             lda  P8ZP_SCRATCH_B1 | ||||
|             sta  save_SCRATCH_ZPB1 | ||||
| @@ -1934,7 +1930,7 @@ save_SCRATCH_ZPWORD2	.word  ? | ||||
|             sta  p8_sys_startup.cleanup_at_exit._exitcode | ||||
|             lda  #0 | ||||
|             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 | ||||
|             sty  p8_sys_startup.cleanup_at_exit._exitcodeY | ||||
|             ldx  prog8_lib.orig_stackpointer | ||||
| @@ -2064,7 +2060,6 @@ asmsub  init_system_phase2()  { | ||||
|  | ||||
| asmsub  cleanup_at_exit() { | ||||
|     ; executed when the main subroutine does rts | ||||
|     ; TODO: Romable | ||||
|     %asm {{ | ||||
|         lda  #1 | ||||
|         sta  $00        ; ram bank 1 | ||||
| @@ -2073,16 +2068,21 @@ asmsub  cleanup_at_exit() { | ||||
|         jsr  cbm.CLRCHN		; reset i/o channels | ||||
|         lda  #9 | ||||
|         jsr  cbm.CHROUT     ; enable charset switch | ||||
| _exitcodeCarry = *+1 | ||||
|         lda  #0 | ||||
|         lda  _exitcarry | ||||
|         lsr  a | ||||
| _exitcode = *+1 | ||||
|         lda  #0        ; exit code possibly modified in exit() | ||||
| _exitcodeX = *+1 | ||||
|         ldx  #0 | ||||
| _exitcodeY = *+1 | ||||
|         ldy  #0 | ||||
|         lda  _exitcode | ||||
|         ldx  _exitcodeX | ||||
|         ldy  _exitcodeY | ||||
|         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() { | ||||
|         ; TODO: Romable | ||||
|         %asm {{ | ||||
|             lda  P8ZP_SCRATCH_B1 | ||||
|             sta  save_SCRATCH_ZPB1 | ||||
| @@ -431,7 +430,7 @@ save_SCRATCH_ZPWORD2	.word  ? | ||||
|             sta  p8_sys_startup.cleanup_at_exit._exitcode | ||||
|             lda  #0 | ||||
|             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 | ||||
|             sty  p8_sys_startup.cleanup_at_exit._exitcodeY | ||||
|             ldx  prog8_lib.orig_stackpointer | ||||
| @@ -606,7 +605,6 @@ cx16 { | ||||
|     &byte r15sH = $7fff | ||||
|  | ||||
|     asmsub save_virtual_registers() clobbers(A,Y) { | ||||
| 		; TODO: Romable | ||||
|         %asm {{ | ||||
|             ldy  #31 | ||||
|     -       lda  cx16.r0,y | ||||
| @@ -671,18 +669,22 @@ asmsub  init_system_phase2()  { | ||||
|  | ||||
| asmsub  cleanup_at_exit() { | ||||
|     ; executed when the main subroutine does rts | ||||
|     ; TODO: Romable | ||||
|     %asm {{ | ||||
| _exitcodeCarry = *+1 | ||||
|         lda  #0 | ||||
|         lda  _exitcarry | ||||
|         lsr  a | ||||
| _exitcode = *+1 | ||||
|         lda  #0        ; exit code possibly modified in exit() | ||||
| _exitcodeX = *+1 | ||||
|         ldx  #0 | ||||
| _exitcodeY = *+1 | ||||
|         ldy  #0 | ||||
|         lda  _exitcode | ||||
|         ldx  _exitcodeX | ||||
|         ldy  _exitcodeY | ||||
|         rts | ||||
|  | ||||
|         .section BSS | ||||
| _exitcarry  .byte ? | ||||
| _exitcode   .byte ? | ||||
| _exitcodeX  .byte ? | ||||
| _exitcodeY  .byte ? | ||||
|         .send BSS | ||||
|  | ||||
|         ; !notreached! | ||||
|     }} | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user