Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: joshuarpl on March 24, 2019, 09:53:49 pm
-
I think I learned that jr F1 is to loop an assembly program, but how do you loop an assembly program but have the option to press CLEAR to quit?
-
A simple way is to do something like:
loop:
bcall(_GetCSC)
cp 15 ; check [clear]
jr nz,loop
ret
But if you want the more complicated (and less energy efficient :P) way:
di ;disables interrupts since the OS will mess with port 1
ld a,$FD ;we'll be polling for keys [ENTER] up to [CLEAR]
out (1),a
loop:
in a,(1)
and $40 ;checks bit 6 which corresponds to clear. Set if not pressed, reset if pressed
jr nz,loop
ret
But my preferred way is:
ei ;keep OS interrupts active
loop:
halt ;
ld a,(kbdScanCode)
cp 15
jr nz,loop
ret
-
Found my own way!
Hex
:AsmPrgm
:EF1840
:FE0F
:C8
:18F1
:C9
Assembly
bcall $4018
cp 0F
ret z
jr F1
ret
Didn't try your code, but still, thanks for helping me out a little bit.
Also, I tested it on my physical TI-84+ and Wabbitemu, and they both act the same, they both work.
-
Found my own way!
Hex
:AsmPrgm
:EF1840
:FE0F
:C8
:18F1
:C9
Assembly
bcall $4018
cp 0F
ret z
jr F1
ret
Didn't try your code, but still, thanks for helping me out a little bit.
Also, I tested it on my physical TI-84+ and Wabbitemu, and they both act the same, they both work.
Note that jr $F1 will only work if the opcode is always at the exact same spot in the program (i.e. 7 bytes into the program). Also, it kinda seems to me like you're trying to do coding on-calc/without a computer. If that's the case, I would advise using Mimas. It's a really nice app where you can write and compile ASM programs on-calc, and it's definitely much better than working in raw hex.
-
Actually, jp points to a fixed location whereas jr is relative. So in this case, jr $F1 (18F1) just states that it will jump back 15 bytes from the end of the instruction.
-
Actually, jp points to a fixed location whereas jr is relative. So in this case, jr $F1 (18F1) just states that it will jump back 15 bytes from the end of the instruction.
Yeah, I meant the opcode itself, not the address it jumps to. In hindsight, that wasn't the best way to put it, but my point about writing in hex still stands.
-
@Sue Doenim : It's true that most would prefer writing in ASM over hex, but in replying to Xeda you may have found one of the few people that started off in writing things in hex and was comfortable doing it for quite some time. Just a funny coincidence. ;)
-
Regardless, it still works.