Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Broseph Radson on January 18, 2011, 08:00:15 pm
-
Im experimenting with interrupts since i just figured out how they could be used if i want to make a graphical shell (not that i can do any other part of making a shell BESIDES graphics and menus lol). I have this:
fnInt(S,0)
ClrHome
"A->A
Lbl 1
Disp A
Repeat getKey(15)
End
FnOff //to be safe
LnReg
Return
Lbl S //Interrupt subroutine
If getKey(54)
Goto 1
End
Return
It exits when i press Clear, but when i press 2nd, it doesnt jump to Lbl 1. Am i using the interrupt wrong or do i just have the wrong idea of how they work?
-
Try not to jump around when you're in an interrupt. An interrupt is kinda like a subroutine: it ends with a Return, and if you don't, it'll just keep calling it over and over until it crashes.
-
Oh so something like
fnInt(S,0)
ClrHome
"A->A
Lbl 1
Disp A
Repeat getKey(15)
If C
0->C
Goto 1
End
End
FnOff //to be safe
LnReg
Return
Lbl S //Interrupt subroutine
getKey(54)->C
Return
Also, can i call a regular subroutine from within an interrupt like
Lbl S //interrupt
If getKey(54)
sub(AB)
End
Return
?
EDIT:
Just tried both methods. Neither one worked.
-
Why do you need the getKey() in the interrupt though? It's a lot easier if it's just in the program loop.
-
Something like a teacher key where i can press it anywhere in the program and it works. Saves space in exchange for slightly less speed.
-
Well an interrupt is basically like a sub( that the calculator is forced to call every once in a while. So if you do something like
:Lbl I
:Return
:...
:Lbl S . Interrupt
:If getKey(54)
:Goto I
all that the Return in Lbl I does is return from the subroutine, back to the program.
If you call I instead of using Goto , as in
:Lbl I
:Return
:...
:Lbl S . Interrupt
:If getKey(54)
:sub(I)
:Return
the Return in Lbl I returns to the subroutine, which returns to the main program.
-
ClrHome
fnInt(S,0)
sub(A)
Repeat getKey(15)
End
FnOff
LnReg
Return
Lbl A
Disp 123>Dec
Disp i //imaginary i
Return
Lbl S
If getKey(54)
sub(A)
End
Return
It still doesnt register that im pressing 2nd
-
*bumpity*
-
It looks correct, I don't see any errors. The only thing I can can think of is that maybe the Disp command cannot be used with custom interrupts because it uses an OS routine but I kind of doubt that.
-
It works with disp i believe. The same program using a timer instead of keypresses works fine, but when i make it wait for a keypress instead of just incrementing a number on each interrupt, it stops working. It reads the clear key fine and breaks the Repeat when i press it. Maybe a bug? EDIT: it appears that its not the keypress thats the problem, its that interrupts cant call subroutines. Man this is confusing
-
How about:
//Main loop
ReturnIf A=-1
...
Lbl S
If getkey(54)
-1->A
End
Return
-
The only problem with that is that you still have to test for the keypress in every loop, just indirectly. Im trying to make it so you dont have to test for it in any loops, it just automatically tests for it.
-
Here is the ASM to add in:
Asm(E1)
This will pop the last entry off the stack. This way, if it returns, it will return to the original address, I think.
Archive the source before trying. If Quigibo had Axe push something extra onto he stack, then it will be a problem.