Hey all!
I recently started asm for the ti-84 and was wondering why this only displayed "1":
Code: .NOLIST
#include "ti83plus.inc"
.LIST
.org 9d95h
.db t2ByteTok, tAsmCmp
b_call(_RunIndicOff)
b_call(_ClrLCDFull)
LD DE, 1
JR Display
Add:
INC DE
JP Z, Done
JR Display
Display:
LD HL, 0
LD (CurRow), HL
LD H, D
LD L, E
PUSH DE
b_call(_DispHL)
POP DE
JR Add
Done:
ret
.end
.end
It should just increment DE until the carry flag is set?
Quote:
Add:
INC DE
JP Z, Done
JR Display
What part of your program sets the zero flag?
Also, welcome to Cemetech! You can introduce yourself in the appropriate topic.
Edit: use .org 9d93, not 9d95.
[
INC affects the carry flag right?
toraora wrote:
INC affects the carry flag right?
It does, when an overflow occurs.
Quote:
It should just increment DE until the carry flag is set?
First of all, it will take a long time to overflow a 16 bit number (maybe wrong?). Second, you should use jr c,Done, not jp z,Done.
You also don't need to use DE and HL, you can just use HL and save a couple of bytes.
The program now just displays a "1", then exits. Before it wouldn't even exit. Shouldn't it be displaying 1-65535?
Change your jp z,Done to a jr c,Done.
Did you change the .org 9d95h to a .org 9d93h?
Actually, change the jr c,Done to a jr nc,Done.
Welcome to Cemetech, Toraora. Try this:
Code: .NOLIST
#include "ti83plus.inc"
.LIST
.org 9d93h
.db t2ByteTok, tAsmCmp
b_call(_RunIndicOff)
b_call(_ClrLCDFull)
LD DE, 1
JR Display
Add:
inc de
ret c
Display:
LD HL, 0
LD (CurRow), HL
LD H, D
LD L, E
PUSH DE
b_call(_DispHL)
POP DE
JR Add
Done:
ret
.end
.end
Should we first reset the carry flag
Kerm, that code doesn't work. Do you need to reset the carry flag, and if you do, do you put or a before the " JR Display "?
souvik1997 wrote:
Kerm, that code doesn't work.
What doesn't work about it? And toraora, no need to reset the carry flag. you aren't checking the carry without first incrementing de, which will reset the carry flag if it doesn't overflow. If you really want to reset the flag, though, it's either 'or a' or 'scf \ ccf'.
It exits after displaying "1".
After DE reaches 65535, instead of the program exiting, it will simply start back at 0. (I reset the carry with "OR A" before inc de)
toraora wrote:
After DE reaches 65535, instead of the program exiting, it will simply start back at 0. (I reset the carry with "OR A" before inc de)
Then after the inc de, do "ld a,d \ or e \ ret z" to return when de overflows back to zero. That's not the same result that Souvik was reporting, though.
Only if you exclude the carry flag reset, then you get what Souvik reported.
toraora wrote:
Only if you exclude the carry flag reset, then you get what Souvik reported.
Then that tells me that inc de doesn't touch the carry flag at all, which we probably could have figured out from Ben's favorite resource. My fix should do the trick for you.
8-bit inc/dec do not touch the carry flag, and 16-bit inc/dec affect no flags at all.
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.
»
Go to Registration page
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum