Page 1 of 2

interrupts on flash debugger

Posted: Thu 11 Dec, 2008 4:32 pm
by Batman
for some odd reason, my interrupt i made for a program will only run once, the thing is though, that nowhere in the interrupt or the program do i di. and another thing, once i im2 then ei, it will sometimes immediatly go to the interrupt, and sometimes it takes it a little while... any help???

Re: interrupts on flash debugger

Posted: Thu 11 Dec, 2008 6:44 pm
by benryves
Do you acknowledge the interrupts? See here for an example.

Re: interrupts on flash debugger

Posted: Thu 11 Dec, 2008 8:54 pm
by calc84maniac
Batman wrote:for some odd reason, my interrupt i made for a program will only run once, the thing is though, that nowhere in the interrupt or the program do i di. and another thing, once i im2 then ei, it will sometimes immediatly go to the interrupt, and sometimes it takes it a little while... any help???
When you enter an interrupt, interrupts are temporarily disabled. Before returning, make sure they are enabled by either using "reti" to return or doing an "ei \ ret".

Re: interrupts on flash debugger

Posted: Thu 11 Dec, 2008 9:30 pm
by benryves
calc84maniac wrote:When you enter an interrupt, interrupts are temporarily disabled. Before returning, make sure they are enabled by either using "reti" to return or doing an "ei \ ret".
RETI doesn't affect IFF1 or IFF2; it's to support daisy-chained interrupts (on the hardware level). You still need to EI when using RETI. RETN, on the other hand, copies IFF2 back to IFF1, which is useful with non-maskable interrupts (the Z80 copies IFF1 to IFF2 before restarting at $66).

Re: interrupts on flash debugger

Posted: Fri 12 Dec, 2008 4:28 pm
by Batman
so are you saying that i should
ei
reti

at the end of the interrupt?


;i had no idea that interrupts automatically disable interrupts once they are run. that kinda makes sense though i guess so that an interrupt isn't run during the interrupt... :puzzled:

Re: interrupts on flash debugger

Posted: Fri 12 Dec, 2008 4:48 pm
by benryves
EI \ RET or EI \ RETI will both work (RETI isn't required as the TI hardware doesn't use daisy-chained interrupts). EI itself has a one-instruction delay, so interrupts are only enabled after the RETI.

My service routine looks like this:

Code: Select all

Handler:
	
	push af
	
	in a,(4) ; Get source of interrupt.

	bit 0,a
	jr z,InterruptNotOnKey
		push af
		
		; Handle ON key interrupts.
		
		pop af	
	InterruptNotOnKey:
	
	bit 1,a
	jp z,InterruptNotTimer1
		push af
		
		; Handle timer 1 interrupts.
		
		pop af
	InterruptNotTimer1:
	
	; Acknowledge/re-enable:
	ld a,%00001000 ; Disable/ack all interrupts; keep calc powered.
	out (3),a
	ld a,%00001011 ; Enable timer interrupt 1 and ON key.
	out (3),a
	ld a,%00000110 ; Slowest speed.
	out (4),a
	
	pop af
	ei
	reti
I back up registers to the stack; if you don't need to preserve the shadow registers you could just use EXX (like the TI-OS ISR).

Re: interrupts on flash debugger

Posted: Mon 15 Dec, 2008 4:28 pm
by Batman
wow, thats cool. well, i figured it out thanks to yours' help...

xor a
out ($03), a
di

;interrupt here

ld a, %00010011
out ($03),a
ei
ret


correct right???
Thanx!

Re: interrupts on flash debugger

Posted: Mon 15 Dec, 2008 4:51 pm
by benryves
Interrupts are automatically disabled (IFF1 and IFF2 are reset) before the CPU jumps to your interrupt service routine, so you don't need that DI in there. I'd recommend flicking through the interrupts section in the official Z80 user manual.
xor a
out ($03), a
That will switch the calculator off (low power mode) if you HALT, you probably don't want to do that. Output %00001000 rather than 0.
ld a, %00010011
out ($03),a
That too will switch of the calculator when it goes into HALT. It also enables the link port interrupt; maybe you want %0001011? See here for a more thorough description of the bits.

Reading port 4 will tell you which piece of hardware (on key, timer, link port) generated the interrupt.

Re: interrupts on flash debugger

Posted: Tue 16 Dec, 2008 8:36 am
by tr1p1ea
Im not sure the flash debugger emulates interrupts properly either way :X.

Re: interrupts on flash debugger

Posted: Tue 16 Dec, 2008 4:04 pm
by Batman
you know what?, I think you are right about it not handling interrupts right, cause when i coded it, it worked perfectly, no mistakes... but when i sent i to my ti 84+, it just said "done" after execution... what's the deal with that??? did yall want to take a look at it?

Re: interrupts on flash debugger

Posted: Tue 16 Dec, 2008 4:06 pm
by benryves
BBC BASIC is unusable in Flash Debugger too. The moral of the story is: don't test your apps in Flash debugger, use PindurTI, Wabbitemu or similar. :(

Re: interrupts on flash debugger

Posted: Tue 16 Dec, 2008 4:09 pm
by Batman
that pindur ti says, "not a valid win 32 application"???

question, what have you made as far as asm games go???

finished ones of course...

Re: interrupts on flash debugger

Posted: Tue 16 Dec, 2008 10:32 pm
by benryves
Batman wrote:that pindur ti says, "not a valid win 32 application"???
Try downloading it again? Which OS are you using?
question, what have you made as far as asm games go??? finished ones of course...
http://www.ticalc.org/archives/files/au ... /6296.html, though how is that relevant?

Re: interrupts on flash debugger

Posted: Fri 19 Dec, 2008 2:19 pm
by Batman
sorry, i got it to working, though i don't really know much about roms...
but i have it so that i can open up the prog. in it so its ok...
Well i didn't want to offend you but you are pretty smart at programming and i wanted to know some of the works that you have done...
Quite impressive, I guess you aren't in high school... were did you learn programming like that??? It's Awsome! 8)

Re: interrupts on flash debugger

Posted: Fri 19 Dec, 2008 2:30 pm
by benryves
The .clc files in the Flash Debugger installation directory are usable ROMs.
Quite impressive, I guess you aren't in high school... were did you learn programming like that??? It's Awsome! 8)
Cheers. :) I work, but learned most of my Z80 programming from CoBB's Z80 documentation and AsmGuru.