mirror of
				https://github.com/irmen/prog8.git
				synced 2025-10-31 00:16:08 +00:00 
			
		
		
		
	set X to bottom part of eval stack in irq handler. fixes #94
This commit is contained in:
		| @@ -340,8 +340,7 @@ _modified	jsr  $ffff                      ; modified | ||||
| _use_kernal     .byte  0 | ||||
|  | ||||
| _irq_handler_init | ||||
| 		; save all zp scratch registers and the X register as these might be clobbered by the irq routine | ||||
| 		stx  IRQ_X_REG | ||||
| 		; save all zp scratch registers as these might be clobbered by the irq routine | ||||
| 		lda  P8ZP_SCRATCH_B1 | ||||
| 		sta  IRQ_SCRATCH_ZPB1 | ||||
| 		lda  P8ZP_SCRATCH_REG | ||||
| @@ -354,18 +353,15 @@ _irq_handler_init | ||||
| 		sta  IRQ_SCRATCH_ZPWORD2 | ||||
| 		lda  P8ZP_SCRATCH_W2+1 | ||||
| 		sta  IRQ_SCRATCH_ZPWORD2+1 | ||||
| 		; stack protector; make sure we don't clobber the top of the evaluation stack | ||||
| 		dex | ||||
| 		dex | ||||
| 		dex | ||||
| 		dex | ||||
| 		dex | ||||
| 		dex | ||||
| 		; Set X to the bottom 32 bytes of the evaluation stack, to HOPEFULLY not clobber it. | ||||
| 		; This leaves 128-32=96 stack entries for the main program, and 32 stack entries for the IRQ handler. | ||||
| 		; We assume IRQ handlers don't contain complex expressions taking up more than that. | ||||
| 		ldx  #32 | ||||
| 		cld | ||||
| 		rts | ||||
|  | ||||
| _irq_handler_end | ||||
| 		; restore all zp scratch registers and the X register | ||||
| 		; restore all zp scratch registers | ||||
| 		lda  IRQ_SCRATCH_ZPB1 | ||||
| 		sta  P8ZP_SCRATCH_B1 | ||||
| 		lda  IRQ_SCRATCH_ZPREG | ||||
| @@ -378,10 +374,8 @@ _irq_handler_end | ||||
| 		sta  P8ZP_SCRATCH_W2 | ||||
| 		lda  IRQ_SCRATCH_ZPWORD2+1 | ||||
| 		sta  P8ZP_SCRATCH_W2+1 | ||||
| 		ldx  IRQ_X_REG | ||||
| 		rts | ||||
|  | ||||
| IRQ_X_REG		.byte  0 | ||||
| IRQ_SCRATCH_ZPB1	.byte  0 | ||||
| IRQ_SCRATCH_ZPREG	.byte  0 | ||||
| IRQ_SCRATCH_ZPWORD1	.word  0 | ||||
|   | ||||
| @@ -384,8 +384,7 @@ _modified	jsr  $ffff                      ; modified | ||||
| _use_kernal     .byte  0 | ||||
|  | ||||
| _irq_handler_init | ||||
| 		; save all zp scratch registers and the X register as these might be clobbered by the irq routine | ||||
| 		stx  IRQ_X_REG | ||||
| 		; save all zp scratch registers as these might be clobbered by the irq routine | ||||
| 		lda  P8ZP_SCRATCH_B1 | ||||
| 		sta  IRQ_SCRATCH_ZPB1 | ||||
| 		lda  P8ZP_SCRATCH_REG | ||||
| @@ -398,18 +397,15 @@ _irq_handler_init | ||||
| 		sta  IRQ_SCRATCH_ZPWORD2 | ||||
| 		lda  P8ZP_SCRATCH_W2+1 | ||||
| 		sta  IRQ_SCRATCH_ZPWORD2+1 | ||||
| 		; stack protector; make sure we don't clobber the top of the evaluation stack | ||||
| 		dex | ||||
| 		dex | ||||
| 		dex | ||||
| 		dex | ||||
| 		dex | ||||
| 		dex | ||||
| 		; Set X to the bottom 32 bytes of the evaluation stack, to HOPEFULLY not clobber it. | ||||
| 		; This leaves 128-32=96 stack entries for the main program, and 32 stack entries for the IRQ handler. | ||||
| 		; We assume IRQ handlers don't contain complex expressions taking up more than that. | ||||
| 		ldx  #32 | ||||
| 		cld | ||||
| 		rts | ||||
|  | ||||
| _irq_handler_end | ||||
| 		; restore all zp scratch registers and the X register | ||||
| 		; restore all zp scratch registers | ||||
| 		lda  IRQ_SCRATCH_ZPB1 | ||||
| 		sta  P8ZP_SCRATCH_B1 | ||||
| 		lda  IRQ_SCRATCH_ZPREG | ||||
| @@ -422,10 +418,8 @@ _irq_handler_end | ||||
| 		sta  P8ZP_SCRATCH_W2 | ||||
| 		lda  IRQ_SCRATCH_ZPWORD2+1 | ||||
| 		sta  P8ZP_SCRATCH_W2+1 | ||||
| 		ldx  IRQ_X_REG | ||||
| 		rts | ||||
|  | ||||
| IRQ_X_REG		.byte  0 | ||||
| IRQ_SCRATCH_ZPB1	.byte  0 | ||||
| IRQ_SCRATCH_ZPREG	.byte  0 | ||||
| IRQ_SCRATCH_ZPWORD1	.word  0 | ||||
|   | ||||
| @@ -729,8 +729,7 @@ _modified	jsr  $ffff                      ; modified | ||||
| _use_kernal     .byte  0 | ||||
|  | ||||
| _irq_handler_init | ||||
| 		; save all zp scratch registers and the X register as these might be clobbered by the irq routine | ||||
| 		stx  IRQ_X_REG | ||||
| 		; save all zp scratch registers as these might be clobbered by the irq routine | ||||
| 		lda  P8ZP_SCRATCH_B1 | ||||
| 		sta  IRQ_SCRATCH_ZPB1 | ||||
| 		lda  P8ZP_SCRATCH_REG | ||||
| @@ -743,18 +742,15 @@ _irq_handler_init | ||||
| 		sta  IRQ_SCRATCH_ZPWORD2 | ||||
| 		lda  P8ZP_SCRATCH_W2+1 | ||||
| 		sta  IRQ_SCRATCH_ZPWORD2+1 | ||||
| 		; stack protector; make sure we don't clobber the top of the evaluation stack | ||||
| 		dex | ||||
| 		dex | ||||
| 		dex | ||||
| 		dex | ||||
| 		dex | ||||
| 		dex | ||||
| 		; Set X to the bottom 32 bytes of the evaluation stack, to HOPEFULLY not clobber it. | ||||
| 		; This leaves 128-32=96 stack entries for the main program, and 32 stack entries for the IRQ handler. | ||||
| 		; We assume IRQ handlers don't contain complex expressions taking up more than that. | ||||
| 		ldx  #32 | ||||
| 		cld | ||||
| 		rts | ||||
|  | ||||
| _irq_handler_end | ||||
| 		; restore all zp scratch registers and the X register | ||||
| 		; restore all zp scratch registers | ||||
| 		lda  IRQ_SCRATCH_ZPB1 | ||||
| 		sta  P8ZP_SCRATCH_B1 | ||||
| 		lda  IRQ_SCRATCH_ZPREG | ||||
| @@ -767,10 +763,8 @@ _irq_handler_end | ||||
| 		sta  P8ZP_SCRATCH_W2 | ||||
| 		lda  IRQ_SCRATCH_ZPWORD2+1 | ||||
| 		sta  P8ZP_SCRATCH_W2+1 | ||||
| 		ldx  IRQ_X_REG | ||||
| 		rts | ||||
|  | ||||
| IRQ_X_REG		.byte  0 | ||||
| IRQ_SCRATCH_ZPB1	.byte  0 | ||||
| IRQ_SCRATCH_ZPREG	.byte  0 | ||||
| IRQ_SCRATCH_ZPWORD1	.word  0 | ||||
|   | ||||
| @@ -3,7 +3,6 @@ TODO | ||||
|  | ||||
| For next minor release | ||||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||||
| - fix Github issue with X register https://github.com/irmen/prog8/issues/94 | ||||
| - fix Github issue with array problems https://github.com/irmen/prog8/issues/99 | ||||
| - fix IR/VM: animals.p8 example is borked, it jumps straight to a suggestion and then somehow doesn't print the animal name correctly in the first question, and exits after 1 animal instead of looping | ||||
|   this has happened after v8.7:  caused by c21913a6  ir: keep order of children in block  22-11-2022 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user