Author | Comment |
im_an_alien Marine Posted: 4 Oct 2007 17:42 GMT Total Posts: 29 | I'm learning TI-86 ASM with this tutorial: http://www.asm86.cwc.net/
I've just gotten to the part about comparing and conditions, and decided to edit the getkey example to use the whole screen, filling left to right and only putting a new line in after it's filled up the screen. Here's my code:
#include "ti86asm.inc" .org $d748 call _clrScrn call _homeup xor b LoopStart: call _getkey cp kExit call z,_newline ret z cp kEnter jr nz,LoopStart ld a,42 call _putc inc b ld a,b cp 20 call z,_newline xor b jr LoopStart .end
It works fine, but it newlines after only 20 characters on the first line. The output after you press enter a bunch looks like this:
******************** ********************* *********************
Why does it do that, and what can I do to fix it? |
threefingeredguy Ghost
Posted: 5 Oct 2007 06:49 GMT Total Posts: 1189 | That is odd. The only thing I can say is make sure that your registers and flags are preserved when using the OS calls.
--- Someone call for an exterminator? |
tifreak8x Administrator
Posted: 5 Oct 2007 07:34 GMT Total Posts: 419 | Might look through here: http://guide.ticalc.org/ and make sure the information you have is correct.
--- Bringing you Pokemon, for your calculator. |
im_an_alien Marine Posted: 7 Oct 2007 19:34 GMT Total Posts: 29 | Another question: I just (tried to :P) wrote a routine to divide 2 numbers with a remainder, but it seems to throw the calc into an infinite loop. Am I doing something wrong with the carry flag part (check if done dividing)?
#include "ti86asm.inc"
.org _asm_exec_ram
ld a,30 ld b,7 call Division ret
Division: ld e,0 ld d,a xor a ;Getting ready: Setting c ro 0 ld c,a Start: push de ;Check if done dividing ld a,d sub b add a,255 jp nc,Done ;If so, skip to Done pop de ;Not done, subtract b from a and add 1 to result ld a,d sub b inc c jp Start ;Go back and do it again Done: pop de ;Store the results in the right registers ld d,a ld a,c ret
.end |
im_an_alien Marine Posted: 12 Oct 2007 21:42 GMT Total Posts: 29 | Nvm, I found it. The carry flag is always set :P. Any ideas on how to do it better? |