interrupts on flash debugger

A General Discussion forum for TI calculators

Moderator: MaxCoderz Staff

User avatar
Batman
New Member
Posts: 71
Joined: Thu 29 May, 2008 1:44 pm
Location: Over the Rainbow

interrupts on flash debugger

Post 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???
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: interrupts on flash debugger

Post by benryves »

Do you acknowledge the interrupts? See here for an example.
User avatar
calc84maniac
Regular Member
Posts: 112
Joined: Wed 18 Oct, 2006 7:34 pm
Location: The ex-planet Pluto
Contact:

Re: interrupts on flash debugger

Post 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".
~calc84maniac has spoken.

Projects:
F-Zero 83+
Project M (Super Mario for 83+)
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: interrupts on flash debugger

Post 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).
User avatar
Batman
New Member
Posts: 71
Joined: Thu 29 May, 2008 1:44 pm
Location: Over the Rainbow

Re: interrupts on flash debugger

Post 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:
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: interrupts on flash debugger

Post 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).
User avatar
Batman
New Member
Posts: 71
Joined: Thu 29 May, 2008 1:44 pm
Location: Over the Rainbow

Re: interrupts on flash debugger

Post 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!
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: interrupts on flash debugger

Post 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.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Re: interrupts on flash debugger

Post by tr1p1ea »

Im not sure the flash debugger emulates interrupts properly either way :X.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
Batman
New Member
Posts: 71
Joined: Thu 29 May, 2008 1:44 pm
Location: Over the Rainbow

Re: interrupts on flash debugger

Post 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?
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: interrupts on flash debugger

Post 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. :(
User avatar
Batman
New Member
Posts: 71
Joined: Thu 29 May, 2008 1:44 pm
Location: Over the Rainbow

Re: interrupts on flash debugger

Post 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...
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: interrupts on flash debugger

Post 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?
User avatar
Batman
New Member
Posts: 71
Joined: Thu 29 May, 2008 1:44 pm
Location: Over the Rainbow

Re: interrupts on flash debugger

Post 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)
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: interrupts on flash debugger

Post 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.
Post Reply