[TI ASM] Ans questions

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

Post Reply
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

[TI ASM] Ans questions

Post by King Harold »

if Ans is a string, would it be like:
size LSB, size MSB, tAns, stringbytes
or does it work totaly different?
sdk83pguide isnt really helping me with this, it doesnt really explain how Ans is handled (with different types, no sizebytes when its real, etc)

also StoAns is a bit strange..
OP1[,OP2] = value if real [complex]
Otherwise OP1 = name of variable that contains the data to store into Ans
does that mean Ans could contain an appvar or program?
and how would one store a string to Ans? (strings arent "real" or "complex" values, and "name of variable" doesnt really sound usefull either)
would it be better just to store to Str0 or something?
Gambit
Sir Posts-A-Lot
Posts: 252
Joined: Mon 21 Feb, 2005 5:34 am
Location: Laveen, Arizona

Re: [TI ASM] Ans questions

Post by Gambit »

King Harold wrote:if Ans is a string, would it be like:
size LSB, size MSB, tAns, stringbytes
or does it work totaly different?
sdk83pguide isnt really helping me with this, it doesnt really explain how Ans is handled (with different types, no sizebytes when its real, etc)
Like any other variable, the data portion of Ans has those two size bytes, followed by the actual data (no token in between).
King Harold wrote:also StoAns is a bit strange..
OP1[,OP2] = value if real [complex]
Otherwise OP1 = name of variable that contains the data to store into Ans
does that mean Ans could contain an appvar or program?
and how would one store a string to Ans? (strings arent "real" or "complex" values, and "name of variable" doesnt really sound usefull either)
would it be better just to store to Str0 or something?
Interesting question. I don't know what would happen if you set the type byte to ProgObj or AppVarObj (there's speculation, but nobody has actually tried it). :)

I haven't actually used StoAns before, but by reading the Sys. Routines, it looks like you have to create a temporary variable with the string data (that's discussed somewhere in the SDK) and pass that as the "OP1 = name of variable that contains data." Otherwise, you'd have to store the string to a string variable like Str0 and use that as the "name of variable that contains the data."
"If SOURCE is outlawed, only outlaws will have SOURCE."
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

ok thanx a lot
(i might print the whole SDK and read it at school, i have more time there)
if Ans would be a program..
then would typing Ans in the homescreen give you ERR:INVALID?
(it didnt get a "execute basic prog"-type-of-command so you would be trying to paste a whole bunch of senseless bytes somewhere)

isnt Ans a "Token based variable" though?
sizebytes, tAns, 0, 0, ??, ??, ?? etc
Gambit
Sir Posts-A-Lot
Posts: 252
Joined: Mon 21 Feb, 2005 5:34 am
Location: Laveen, Arizona

Post by Gambit »

King Harold wrote:isnt Ans a "Token based variable" though?
sizebytes, tAns, 0, 0, ??, ??, ?? etc
Yes and no. The data is filled with tokens. If you were to B_CALL AnsName, you'd get the following in OP1:

Code: Select all

.db some_obj_byte,tAns,0,0
Where some_obj_byte has what type of variable Ans is (e.g. StrngObj, MatObj, RealObj, etc.). You'd then proceed with RclVarSym or whatever you want. :)
"If SOURCE is outlawed, only outlaws will have SOURCE."
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

ok so if i want to see whether Ans is a string

Code: Select all

bcall(_AnsName)
ld a,(OP1)
cp StrngObj
jr nz,nostring
;here it should be a string
and then i "RclVarSym" it and skip size (2 times inc de?) and then im right at the first token right?
Gambit
Sir Posts-A-Lot
Posts: 252
Joined: Mon 21 Feb, 2005 5:34 am
Location: Laveen, Arizona

Post by Gambit »

That looks OK. I usually just use RclAns and ld a,(hl) \ and %00011111 \ cp Obj to check for something - only one way to find out! ;)
"If SOURCE is outlawed, only outlaws will have SOURCE."
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

i'll try that aswell, looks like it's the same size but it's nto my code so it just has to work better :P
Post Reply