I'm glad to hear that you were able to figure out what you were stuck on. Just a general suggestion on how to approach assembly programming based on watching people attempt and fail to learn it over the years: if you get stuck on a concept or bug in a program, I don't recommend abandoning it and starting another program. I find that people who end up taking that route repeatedly never end up creating reasonable-sized ASM projects, because it's almost inevitable that you'll end up butting heads with extremely obscure and hard-to-trace problems sooner rather than later in your assembly programming career. Of course, we are here to help, so by all means use us as a resource (not a crutch) for your journey through ASM.
When I hit On in an ASM program using _GetKeyRetOff, it loops infinitely. I'm creating a little password program for myself, and I would prefer not to have people 2nd+Quit out of my program. Because I'm using _GetKeyRetOff, you can't do that, but hitting On will cause the user to have to reset the calc.
123outerme wrote:
When I hit On in an ASM program using _GetKeyRetOff, it loops infinitely. I'm creating a little password program for myself, and I would prefer not to have people 2nd+Quit out of my program. Because I'm using _GetKeyRetOff, you can't do that, but hitting On will cause the user to have to reset the calc.
It loops infinitely doing what? What would the preferred behavior be when someone presses 2nd+MODE? It discarding that key combination?
KermMartian wrote:
123outerme wrote:
When I hit On in an ASM program using _GetKeyRetOff, it loops infinitely. I'm creating a little password program for myself, and I would prefer not to have people 2nd+Quit out of my program. Because I'm using _GetKeyRetOff, you can't do that, but hitting On will cause the user to have to reset the calc.
It loops infinitely doing what? What would the preferred behavior be when someone presses 2nd+MODE? It discarding that key combination?

Well, 2nd+MODE and 2nd+On should be discarded. Also, when it loops, it continually runs the code for my main loop (clearing the screen, getting a key, checking that key against keys that can be used, doing some stuff if the key is used, if nothing is found then repeat), where it the key it gets is On, which isn't a key that is used.

Edit: I have an idea. Instead of using _GetKeyRetOff, I'll just set the cursor state flag (2nd on, Alpha on, Alpha Lock on, etc) to it's default off value. Problem is, I don't know what to do or where that is. Could someone help me out?
Is _GetKeyRetOff a bcall? I agree that it would be nice for it to return a key value instead of automatically performing an action (quitting, turning the calc off), but they were written to work with the TI-OS and not our programs. I can't think of a situation where you'd really want to use _GetKey anyway, there are lots of holes in it.
chickendude wrote:
Is _GetKeyRetOff a bcall? I agree that it would be nice for it to return a key value instead of automatically performing an action (quitting, turning the calc off), but they were written to work with the TI-OS and not our programs. I can't think of a situation where you'd really want to use _GetKey anyway, there are lots of holes in it.

_GetKeyRetOff is a bcall. I just edited my post, so I use _GetCSC, which hopefully won't have the looping problem, or it loops regardless of key pressed. So, if someone presses 2nd, I would just revert the cursor state (2nd on, Alpha on, etc) back to it's default, off state.
Edit: Never mind, I got it now. Ignore this EI:
Unedit: I had to go back to _GetKey, which can be 2nd+On quitted. Does anyone know that flag?
Re-edit: Never mind.
I'm using a list of values as a variable, then increasing my flag. How do I have it work like L1(A)?
This is my code:

Code:

ld hl, Variable+(ix)
inc ix

(PS: I know it doesn't work, I was just using it as an example)
Personally, I like the ix register sometimes, but it depends on what you are trying to use it for. Wink So, in this case, to index a 'list' so to speak, you can do something like this:


Code:
List:
 .db 0,0,1,1,2,2,3,3


Code:
 ld ix,List
 ld a,(ix)  ; 0
 ld a,(ix+7)   ; 3

So that's the first and last elements; everything else is just in between. Smile Hope this explains it somewhat! If you have a list that has words instead, just load it in little-endian order to different registers.
MateoConLechuga wrote:
Personally, I like the ix register sometimes, but it depends on what you are trying to use it for. Wink So, in this case, to index a 'list' so to speak, you can do something like this:


Code:
List:
 .db 0,0,1,1,2,2,3,3


Code:
 ld ix,List
 ld a,(ix)  ; 0
 ld a,(ix+7)   ; 3

So that's the first and last elements; everything else is just in between. Smile Hope this explains it somewhat! If you have a list that has words instead, just load it in little-endian order to different registers.

Okay, I got it! Thanks.
Edit: If I want to go to the next element every time I run my code, how would I present the (ix+number)?
I'm a little bit confused by what you mean: Do you just need to get the next element in a loop format? I don't believe that this a great case to use ix, the hl register might be a better option.


Code:
 ld hl,List
Loop:
 ld a,(hl)
 inc hl
 or a
 jr nz,Loop


This keeps looping until it reaches a 0... It can be modified to store whatever into whatever, if you want to. Smile
Of course, you could just do a djnz loop as well. Wink

If you want to jump farther, you can do an"add hl,de", or something similar, or just change how many times you increment.
IX is perfect when you have a list of entries that are several bytes each, for example:

Code:
dataStart:
.db "NAME1---",0   ;** enemy #0
.db 100 ;HP
.db 30 ;MP
.db 20 ;Str
.db 25 ;Def
.db "NAME2---",0   ;** enemy #1
.db 80 ;HP
.db 40 ;MP
.db 20 ;Str
.db 35 ;Def
Here it can be really useful to use IX because you can access the individual parts of each entry easily:

Code:
NAME = 0
HP = 9
MP = 10
STR =11
DEF =12
To access the data, all you have to do is "ld a,(ix+HP)" or "ld a,(ix+DEF)" (assuming ix is pointing to dataStart).

However, using IX is generally pretty slow. It also takes an extra byte or two than using hl/de/bc. If you are scrolling through a list in order from first to last, it's almost always better to use HL. IX in my experience is mostly useful for organizing your code.
MateoConLechuga wrote:
I'm a little bit confused by what you mean: Do you just need to get the next element in a loop format? I don't believe that this a great case to use ix, the hl register might be a better option.


Code:
 ld hl,List
Loop:
 ld a,(hl)
 inc hl
 or a
 jr nz,Loop


This keeps looping until it reaches a 0... It can be modified to store whatever into whatever, if you want to. Smile
Of course, you could just do a djnz loop as well. Wink

If you want to jump farther, you can do an"add hl,de", or something similar, or just change how many times you increment.

Thanks!
chickendude wrote:
IX is perfect when you have a list of entries that are several bytes each, for example:

Code:
dataStart:
.db "NAME1---",0   ;** enemy #0
.db 100 ;HP
.db 30 ;MP
.db 20 ;Str
.db 25 ;Def
.db "NAME2---",0   ;** enemy #1
.db 80 ;HP
.db 40 ;MP
.db 20 ;Str
.db 35 ;Def
Here it can be really useful to use IX because you can access the individual parts of each entry easily:

Code:
NAME = 0
HP = 9
MP = 10
STR =11
DEF =12
To access the data, all you have to do is "ld a,(ix+HP)" or "ld a,(ix+DEF)" (assuming ix is pointing to dataStart).

However, using IX is generally pretty slow. It also takes an extra byte or two than using hl/de/bc. If you are scrolling through a list in order from first to last, it's almost always better to use HL. IX in my experience is mostly useful for organizing your code.

Thank you! This will definitely be useful later on Smile
  
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
Page 2 of 2
» All times are UTC - 5 Hours
 
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

 

Advertisement