Talk:83Plus:Interrupts

From WikiTI
Jump to: navigation, search

This is the test program I ran to check whether the LD A, I/R bug affected my TI-84+SE. Note that it takes advantage of the TA3 ASIC's less-funky IM 2 vectoring to simplify the code; if you have a TA1 or TA2, you'll need to modify the code.

.nolist
#include "ti83plus.inc"
#include "ti83plusaddendum.inc"
.list
timerCount	.equ	101
	.org	userMem - 2
	.db	t2ByteTok, tAsmCmp

	; Delay ports
	xor	a
	out	(pMemDelay), a
	; Set up interrupts
	ld	a, intMaskOnKey | intDisableLowPowerMode
	out	(pIntMask), a
	xor	a	; tmrOff
	out	(pCtstlTmr1Freq), a
	out	(pCtstlTmr2Freq), a
	out	(pCtstlTmr3Freq), a
	; Interrupt handler
	ld	hl, interruptHandler
	ld	(80FFh), hl
	ld	a, 80h
	ld	i, a
	im	2
	; Timer ports
	ld	a, tmrInt
	out	(pCrstlTmr1Cfg), a
	ld	a, timerCount
	out	(pCrstlTmr1Count), a
	ld	a, tmrCpu
	out	(pCrstlTmr1Freq), a
	ld	c, 11h
	; Loop
_:	inc	b
	out	(c), b
	ld	a, i
	jp	po, explode
	jr	-_
quit:
	ex	af, af'
	xor	a	; tmrOff
	out	(pCtstlTmr1Freq), a
	ld	a, 11
	out	(pIntMask), a
	im	0	; Just to be weird!
	ld	hl, strNotExploded
	b_call(_PutS)
	b_call(_NewLine)
	ret

explode:
	xor	a	; tmrOff
	out	(pCtstlTmr1Freq), a
	ld	a, 11
	out	(pIntMask), a
	im	0
	ld	hl, strExplode
	b_call(_PutS)
	b_call(_NewLine)
	ret
	
interruptHandler:
	pop	hl
	ex	af, af'
	in	a, (pIntId)
	;in	a, (pStatus)
	and	intIdOnKeyDown
	jr	z, quit
	; timer generated interrupt, ack and ret
	ld	a, tmrInt
	out	(pCrstlTmr1Cfg), a
	ld	a, timerCount
	out	(pCrstlTmr1Count), a
	ex	af, af'
	ei
	jp	(hl)

strExplode:
	.db	"Explode!!", 0
strNotExploded:
;		 1234567890123456
	.db	"Program ended   "
	.db	"normally.", 0

If someone with a TI-83+ modifies this to run on the TI-83+ and TA1 and TA2 TI-84+/SEs, let me (probably via the Wiki, or IRC) know if your unit DOES show the bug.Dr. D'nar 20:51, 8 March 2013 (UTC)