|
Post by mog42 on Jun 27, 2002 9:34:33 GMT -5
Suppose that you store the name of a string variable to OP1 and look up the string with _chkfindsym.
ld hl,str1 ld de,OP1 ld bc,3 ldir B_CALL(_chkfindsym) str1: .db strngobj,tvarstrng,tstr1
If the string exists, I would like to find out how long it is.
ex de,hl ld c,(hl) inc hl ld b,(hl)
Now the length of the string is stored to bc.
This program came from an assembly language tutorial, but I didn't really understand why it loads the first byte of the length to c. If the string was 7 bytes long, then shouldn't the length bytes be 00h 07h? But if that's true, loading 00h to c and 07h to b would result in bc being equal to 0700h. This isn't the case, though, because the program always loads the right values to b and c. Could someone explain why this program works?
|
|
|
Post by ticalcman on Jun 27, 2002 23:50:03 GMT -5
I never did undstand asm...even when I got it to work. I recommend using VTI's debugging feature.. Send the program to VTI. Right click vti and click enter debugger. Then click in the dissassembly, hit 'g' (meaning goto) and type in 9D95 (where asm progs are loaded). right click and click set breakpoint. now u can exit the debugger, run the asm prog, and then set more breakpoints to see how the ti-83plus works. The best way to learn how the ti-83plus works is by trying out the different asm commands, reading what they do, and see what they do in the VTI emulator. That's how I learned a lot of stuff....But alas...I learn but do not understand. .. .... ....
|
|
|
Post by David L on Jun 29, 2002 14:06:52 GMT -5
This thing with loading the size into BC also confused me when I was an asm newbie.
However, the answer is that the calculator stores the size with the LSB byte first. Thus you need to load that byte into C and the byte after it in B.
If you have a var that is 7 bytes, the size byte pair is 0700h, not 0007
|
|
|
Post by mog42 on Jun 30, 2002 21:33:26 GMT -5
Thanks for the help, Bob and David L. I now understand why you need to load the LSB first when you're getting the size of a variable.
|
|