[TI ASM] storing data
Moderator: MaxCoderz Staff
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
[TI ASM] storing data
i want to store data to the $20's (which are spaces without zero terminating the string)
var:
.db AppVarObj, "Var", $20, $20, $20, $20, $20, 0
how exactly do you do that?
i have some ideas about using
ld hl, (var)
i didnt get it to work though..
EDIT: Link to source
I'll try to keep this up to date as much as possible
var:
.db AppVarObj, "Var", $20, $20, $20, $20, $20, 0
how exactly do you do that?
i have some ideas about using
ld hl, (var)
i didnt get it to work though..
EDIT: Link to source
I'll try to keep this up to date as much as possible
Last edited by King Harold on Sat 12 Aug, 2006 5:45 pm, edited 1 time in total.
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
thanx, but since im a complete idiot i got a name "Var 0: " thats right var+_space+0+: and i think it has something to do with the input not being hex (it cant be since its a list), its a bit odd.. but ok, code looks like this oh and the bug is mostly in trying to input 10 because it just shifts to the next ascii char instead of adding to the next number... it looks messy, but it works anyway (you can actually store more this way right?)
lower then 10 works (ofcourse) just fine
lower then 10 works (ofcourse) just fine
i hope i didnt do something insanely stupid.nolist
#include "ti83plus.inc"
#define ProgStart $9D95
.list
.org ProgStart - 2
.db t2ByteTok, tAsmCmp
bcall(_RclAns) ; recall Ans
ld hl,1 ; 1st element in Real List
bcall(_GetLtoOp1) ; get element
bcall(_ConvOp1) ; returns a as LSByte (and de as the total 16bit value)
or a
JP Z,create_var
dec a
JP Z,del_var
dec a
JP Z,put_int
ret
create_var:
bcall(_RclAns) ;rcl ans because its lost
ld hl, 2 ;2nd list element (size)
bcall(_GetLtoOp1) ;put it in op1
bcall(_ConvOp1) ;make it a number and put it in de
push de ;push de because it gets destructed
bcall(_RclAns) ;ans gets lost somewhere..
ld hl, 3 ;3rd list element (name)
bcall(_GetLtoOp1) ;put it in op1
bcall(_ConvOp1) ;op1 -> de
ld hl, var_name+5
ld a, $30
add a, d
ld d, a
ld a, $30
add a, e
ld e, a
ld (hl), d
inc hl
ld (hl), e
ld hl, var_name
bcall(_mov9toop1)
bcall(_ChkFindSym) ;see if it needs to be deleted
JR C, create_var_2 ;jump if it doesnt exist
bcall(_DelVarArc) ;delete if so
create_var_2:
pop hl ;pop size (was de) in hl, name is still in OP1
bcall(_CreateAppVar) ;duhh..
ret
del_var:
bcall(_RclAns)
ld hl, 2 ;for deleting the name should be in the 2nd element
bcall(_GetLtoOp1) ;2nd element to op1
bcall(_ConvOp1) ;store the number in de
;name generation based on de.. (same as in "create_var")
ld hl, var_name
bcall(_Mov9ToOP1) ;name in op1
bcall(_ChkFindSym) ;check if it exists, cant delete non-existant things
JR C, not_found ;if not found, dont delete
bcall(_DelVar) ;else delete
ld a, 1 ;1 in a
bcall(_SetxxOP1) ;1 in op1
bcall(_StoX) ;op1 in x (tell user that the appvar has (probebly) been deleted
ret
put_int:
ret ;not made yet
var_name:
.db AppVarObj, "Var", $20, $20, $20, $20, $20, 0
not_found:
xor a ;if the appvar has not been found, 0 to a
bcall(_SetxxOp1) ;a to op1
bcall(_StoX) ;op1 to x (0 to x)
ret
char_string:
.db 10,"0123456789"
.end
END
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm
Well, the reason for the space in the variable name is because you ld hl with var_name+5, it should be var_name+4 (it starts at 0, varnmae+0 corresponds to the first byte).
And that whole section could be optimized as such:
ld hl, var_name+4
ld a, $30
add a, d
ld (hl), a
inc hl
ld a, $30
add a, d
ld (hl), a
but I don't think that's your problem. You probably need to load the numbers from OP directly, rather than using the bcall. The bcall concatenates all the numbers. I'm not sure if you can do this or not, but you should try
ld a,(OP1+2)
push af
and $F0
srl a
srl a
srl a
srl a
add a,$30
ld (hl),a
inc hl
pop af
and $0F
add a,$30
ld (hl),a
then do that for every digit you need (that right there SHOULD load the first two digits into your variable, but I'm not sure if it will work).
You could go into a loop:
Again, I don't know that that will work, but if you finetune it, something meaningful should come out of it.
And that whole section could be optimized as such:
ld hl, var_name+4
ld a, $30
add a, d
ld (hl), a
inc hl
ld a, $30
add a, d
ld (hl), a
but I don't think that's your problem. You probably need to load the numbers from OP directly, rather than using the bcall. The bcall concatenates all the numbers. I'm not sure if you can do this or not, but you should try
ld a,(OP1+2)
push af
and $F0
srl a
srl a
srl a
srl a
add a,$30
ld (hl),a
inc hl
pop af
and $0F
add a,$30
ld (hl),a
then do that for every digit you need (that right there SHOULD load the first two digits into your variable, but I'm not sure if it will work).
You could go into a loop:
Code: Select all
ld ix,OP1+2
ld hl,var_name+4
ld b,3
loop:
ld a,(ix)
push af
and $F0
srl a
srl a
srl a
srl a
add a,$30
ld (hl),a
inc hl
pop af
and $0F
add a,$30
ld (hl),a
inc x
inc hl
djnz loop
dec hl
xor a
ld (hl),a
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm
Sure. Start at OP1+5 and var_name+9 then dec ix and dec hl.
Hmm. It would be a lot larger though because, since you're only using a five digit number and not six (odd vs even), the rightmost nibble would have to be skipped the first time through. Actually, you could just ld a,b \ cp 3 \ jr someLabelAfter the second nibble is taken care of.
Well, actually there are a couple other complications as well. You'd have to work the lower nibble first.
Give me a few minutes and I'll edit it so that it should work the other way. But why do you need it to work backwards?
See if that works.
Hmm. It would be a lot larger though because, since you're only using a five digit number and not six (odd vs even), the rightmost nibble would have to be skipped the first time through. Actually, you could just ld a,b \ cp 3 \ jr someLabelAfter the second nibble is taken care of.
Well, actually there are a couple other complications as well. You'd have to work the lower nibble first.
Give me a few minutes and I'll edit it so that it should work the other way. But why do you need it to work backwards?
Code: Select all
ld ix,OP1+5
ld hl,var_name+9
ld b,3
loop:
ld a,b
cp 3
jr z,skip
ld a,(ix)
and $0F
add a,$30
ld (hl),a
skip:
dec hl
ld a,(ix)
and $F0
srl a
srl a
srl a
srl a
add a,$30
ld (hl),a
dec ix
dec hl
djnz loop
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
i need to work backwards because otherwise 3, 30, 300, 3000 and 30000 will all result in the name "Var30000"
because it starts with the 3 and cant put anything else then zero's in the rest....
i think looping over the number backwards should solve the problem, im not sure though..
this code gives me all-zero names..
it looks very much like something that should work though
because it starts with the 3 and cant put anything else then zero's in the rest....
i think looping over the number backwards should solve the problem, im not sure though..
this code gives me all-zero names..
it looks very much like something that should work though
Last edited by King Harold on Tue 08 Aug, 2006 3:43 pm, edited 1 time in total.
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm
Nope. That would still store the zeros. Make the user use 00003 and 00030 etc. I mean, you could read in the number, check if it's a zero, and then skip to the next number (making a zero an illegal number).
Otherwise, I could make a routine that starts at var_name+9 and deletes all zeros (well, either converts them to spaces or to a null value) until it reaches a non-zero. That would be incredibly simple to do.
Otherwise, I could make a routine that starts at var_name+9 and deletes all zeros (well, either converts them to spaces or to a null value) until it reaches a non-zero. That would be incredibly simple to do.
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm
Code: Select all
ld ix,OP1+2
ld hl,var_name+4
ld a,(OP1+1)
sub a,$7F
ld b,a
loop:
ld a,(ix)
push af
and $F0
srl a
srl a
srl a
srl a
add a,$30
ld (hl),a
inc hl
dec b
jr z,exit
pop af
and $0F
add a,$30
ld (hl),a
inc x
inc hl
djnz,loop
exit:
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm
It should be inc ix, sorry! Typo.
And switch this:
Code:
ld ix,OP1+2
ld hl,var_name+4
ld a,(OP1+1)
sub a,$7F
ld b,a
to this:
Code:
ld ix,OP1+2
ld hl,OP1+1
ld a,(hl)
ld hl,var_name+4
sub a,$7F
ld b,a
that should fix it.
Also, tasm should output a .lst file. Open that with notepad or something and on the left it should list the line numbers, then the hex values, then what you typed in your program. I don't know if it deletes it if there's an error, but it might not. It'll prevent you from having to count though
And switch this:
Code:
ld ix,OP1+2
ld hl,var_name+4
ld a,(OP1+1)
sub a,$7F
ld b,a
to this:
Code:
ld ix,OP1+2
ld hl,OP1+1
ld a,(hl)
ld hl,var_name+4
sub a,$7F
ld b,a
that should fix it.
Also, tasm should output a .lst file. Open that with notepad or something and on the left it should list the line numbers, then the hex values, then what you typed in your program. I don't know if it deletes it if there's an error, but it might not. It'll prevent you from having to count though
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am