Page 1 of 3

Utilization des Auto-Ints (92+)

Unread postPosted: 15 Mar 2016, 13:48
by utz
Salut,

mon premier post ici ;) Excusez-moi, la langue française et moi, ça fait deux... mais il semble que la plupart des 68k codeurs sont ici, donc je vais essayer quand même.

J'essaye de compredre l'utilization des Auto-Ints sûr TI92+. Pour le début, je veux simplement détecter si la touche ON est pressée. C'est le Auto-Int 6, non? Alors, j'ai désactivé la protection de memoire (bclr #2,($600001)), et mis un nouveau vecteur à l'adresse $000078. Jusqu'ici tout va bien. Le debugger me montre que le nouveau vecteur est correctement chargé. Mais malhereusement, quand je presse la touche ON, le TI ne suit pas le vecteur. Au lieu de cela, il va crasher avec "ILLEGAL INSTRUCTION". Qu'est-ce que je fais mal?

Edit: Il semble que le vecteur est en effet suivi, mais un erreur est jeté après la fin de l'exécution du programme. Imbalance de stack, peut-être?
Comment le résoudre?

Edit2: Ok, un peut de progrès. Bien sûr, A7 est détruite par l'interrupt. Pas de problem, on peut corriger ça ;) Et maintenant, le programme se termine bien. Mais si je tente de l'exécuter à nouveau, il va se planter avec "Illegal Instruction". Hmmmm...

Re: Utilization des Auto-Ints (92+)

Unread postPosted: 15 Mar 2016, 17:10
by Ti64CLi++
Speak English because your French is bad ;)

Re: Utilization des Auto-Ints (92+)

Unread postPosted: 15 Mar 2016, 17:19
by utz
Ok, sure. I know my French sucks, just didn't want to be impolite...

So, in case my ramblings were to incoherent to comprehend, I'll try to sum them up in English.

I'm trying to figure out how to use the Auto-Ints on 92+. For the time being, I'm simply trying to detect if the ON key is pressed, and exit the program if so. I'm putting a new vector into ($000078) and I've now gotten as far as having it actually execute. I also figured that triggering the interrupt will trash the stack, so I'm restoring it to whatever value it had before. When the interrupt fires, i'm putting the old vector back at ($000078), and the program does a clean exit. But when I try to run it again, the calc will throw an "Illegal Instruction" and freeze. What am I doing wrong?

Re: Utilization des Auto-Ints (92+)

Unread postPosted: 15 Mar 2016, 17:31
by loupiot
you're not the only non french speaker, there is no problem if you speak english here :)

Re: Utilization des Auto-Ints (92+)

Unread postPosted: 15 Mar 2016, 17:59
by Adriweb
I'm pretty sure Lionel Debroux will be able to help you - let's wait until he reads this topic :)

Re: Utilization des Auto-Ints (92+)

Unread postPosted: 15 Mar 2016, 19:29
by Lionel Debroux
Hi utz, nice to see you here :)

You need to (EDIT: or at least, should - that's what most programs do, AFAIK) use port 60001A instead of AUTO_INT_6, like I did for http://www.ticalc.org/archives/files/fi ... 43329.html .
You can find the latest version of the hardware reference mirrored at http://tict.ticalc.org/docs/J89hw.txt .

Don't worry about your French skills. Lots of native French speakers are doing it worse than you are...

Re: Utilization des Auto-Ints (92+)

Unread postPosted: 15 Mar 2016, 19:40
by Hayleia
utz wrote:Ok, sure. I know my French sucks, just didn't want to be impolite...

I wouldn't say you were the impolite one here...

Plus, your French isn't bad at all. The only mistakes I see are :
  • "utilization" instead of "utilisation" (no one cares, it doesn't hurt readability)
  • "un erreur est jeté", instead of "une erreur est jetée" (same, we can see you're not French but it's just a gender issue that doesn't hurt readability)
  • "Imbalance". Ok, only place where people who don't speak English at all can't see what you mean, but on the other hand, they're at fault too...
  • "problem" instead of "problème" (no one cares either)

Re: Utilization des Auto-Ints (92+)

Unread postPosted: 15 Mar 2016, 20:42
by utz
Thanks for the cheers y'all... I'll try some more French later on, but right now my brain's too tired ;)

Ok, so the thing is that I don't want to use the IO ports. I'm writing some timing-critical code (yep, you might have guessed it already - it's a sound driver), and using ports would cost me a lot of cycles, not least because I'd need to balance out the cycle count from the inevitable Bcc. Hence my question: Is there any possibility to directly use AUTO_INT_6, or should I just forget about it? I've deduced that doing so will escalate privileges (enable supervisor mode, that is), but when I try to deescalate that before exiting the program, the calc will immediately freeze with "Illegal Instruction" on exit.

I was also (and more importantly) planning on using AUTO_INT_5, ie. the timer interrupt. Will that cause the same sort of problems, or can it be used safely somehow?

Re: Utilization des Auto-Ints (92+)

Unread postPosted: 15 Mar 2016, 21:01
by Lionel Debroux
using ports would cost me a lot of cycles

I'm not aware using the port for the ON key is slower than letting the interrupt trigger, handling it, and returning. You could benchmark a loop of checking the port using the timer interrupt, anyway :)
Unless checking the port yields special implicit hardware delay (TI-68k ports normally don't for reads not preceded by writes, such as the keyboard ports needing a relatively short delay before reading after writing the row), checking the port will end up being faster.

Hence my question: Is there any possibility to directly use AUTO_INT_6

Sure, that's what the OS does.
Likewise, AUTO_INT_5 is used by lots of programs for their purposes, starting by Geogeo's PolySnd (I contributed several optimizations in the fast path) for producing sound through the legacy I/O port on a TI-68k calculator.

The user and supervisor stacks are fully separate: 0x400-0x41FF for the former, 0x4204-0x4BFF for the latter, stack fence 0xDEADDEAD in-between. Don't try to play weird games and mix the two pointers, and don't forget to use rte instead of rts to return from your interrupt handlers :)

Re: Utilization des Auto-Ints (92+)

Unread postPosted: 15 Mar 2016, 21:19
by utz
Alright, thanks for your advice! I'll have a go at figuring out how to properly return from the interrupt, and study PolySnd, then.

Regarding the speed thing... say I want to check the ON key status during a running sound loop. For reading and evaluating the port, I have to put some code into the loop to handle it. If I use the auto-int on the other hand, no additional code is required within the loop. So naturally, it'll save me a few cycles ;) As far as the actual cycle count of checking the IO port vs handling the interrupt goes, I'm pretty sure IO would indeed be faster. Well, it was more a hypothetical thing, ultimately one shouldn't put the keyhandling into the synth core in the first place :o

Btw, my user stack is sitting somewhere at 3cxx... is that normal? Using a "compressed" prgm btw.

Edit: Just looked into PolySnd a bit. I can't figure out how it's using AUTO_INT_5. There's a move.w #$700,d0, trap #1 at the beginning... so how exactly does this work?