New Appvar utility
Moderator: MaxCoderz Staff
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
New Appvar utility
I know there are milions of them out there, but because im quite disapointed about the "rflib" i got from ticalc.org (doesnt store chars yet and FP storing seems a bit like wasting space to me, asm libs should be much over 1k and you can store a FP number as 9 integers)
nor does it have the ability to enlarge/shrink appvars (which isnt all that hard)
and source code isnt even included (not that it really matters, but its nicer to other ppl if you include it)
So, there i go, im trying to make an appvar lib, but since im me and thus a programming noob it will probebly take a while (i will finish it though, i promise you that, but if it takes 1 year...)
i allready found something that isnt hard but i cant do anyway, which is making the name of the appvar a proper variable so that you can input a name/number for the name, any tips? (if i load hl with a value the names are like ^%#&^*#v is there something like sub(substring. number, length) for asm?)
update: I will probebly make 2 versions for the first release: 1 for speed (no error checking bcalls that take a lot of time) and 1 for safety loaded with error checking and data validating bcalls
nor does it have the ability to enlarge/shrink appvars (which isnt all that hard)
and source code isnt even included (not that it really matters, but its nicer to other ppl if you include it)
So, there i go, im trying to make an appvar lib, but since im me and thus a programming noob it will probebly take a while (i will finish it though, i promise you that, but if it takes 1 year...)
i allready found something that isnt hard but i cant do anyway, which is making the name of the appvar a proper variable so that you can input a name/number for the name, any tips? (if i load hl with a value the names are like ^%#&^*#v is there something like sub(substring. number, length) for asm?)
update: I will probebly make 2 versions for the first release: 1 for speed (no error checking bcalls that take a lot of time) and 1 for safety loaded with error checking and data validating bcalls
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
hmm that doesnt sound like thats the point of my code, have a look:
Code: Select all
.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
ld hl,3 ;3rd list element (name)
bcall(_GetLtoOp1) ;put it in op1
bcall(_ConvOp1) ;make it a number and put it in de (somehow this has to make a name)
;name generation based on de (3rd element of list) (later)
ld hl, var_name ;testingfase namegeneration
bcall(_Mov9ToOP1) ;put the name in hl
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.. (need help on that)
ld hl, var_name ;name in hl
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, "testvar " ;testname untill i make name generation
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
.end
END
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
things like {0,size,name are passed through ans to tell the program what we want it to do
thats checked by the first few lines of code with the jumps
I dont axactly know what is stored in OP1 at RclAns but GetLtoOp1 works with it, and works just fine
hl is the list index and op1 is something with the list that came from ans - that all works fine
I still dont have a working way to create names like this:
"Var"+ 5 digits (integer value 0 - 65536)
in basic this would have been a piece of cake
just
Y being the number to convert
"_ ->Str1
for( X,1,5
Str1+sub("0123456789", iPart(10^(X-1)fPart(Y/(10^x))+1,1)->Str1
End
sub(Str1,2,5)->Str1 (remove space, space is there because of a zero-length bug)
but in assembly....??
thats checked by the first few lines of code with the jumps
I dont axactly know what is stored in OP1 at RclAns but GetLtoOp1 works with it, and works just fine
hl is the list index and op1 is something with the list that came from ans - that all works fine
I still dont have a working way to create names like this:
"Var"+ 5 digits (integer value 0 - 65536)
in basic this would have been a piece of cake
just
Y being the number to convert
"_ ->Str1
for( X,1,5
Str1+sub("0123456789", iPart(10^(X-1)fPart(Y/(10^x))+1,1)->Str1
End
sub(Str1,2,5)->Str1 (remove space, space is there because of a zero-length bug)
but in assembly....??
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm
A variable can have a space in assembly...
So wait, you're trying to create an appvar named VARXXXXX where XXXXX is a number?
Well, when you store something into a floating point variable, each nibble represents a digit.
They take the form:
Sign: $00=positive integer, $80 = negative
Decimal Point location: $80 = x10^0, $81 = x10^1, $7F=x10-1, etc
XX: first X is one digit, second X is another
Sign, DecLocation, XX,XX,XX,XX,XX,XX,XX
Ex: 15,540 would be
$00, $84, $15,$54,$0/\0,$00,$00,$00,$00
where the decimal would be.
I'm fairly certain that that is how the number would be stored in OP1/2/wherever it's stored, all you would need to do is skip the first two bytes of the OP1 register, load it into a, do AND $F0 to clear out the second digit, shift the bits over to the right, append that digit to your appvar name, reload that byte into a, AND $F to clear out the bits corresponding to the first digit, append that to your appvar name, and then go to the next byte and repeat.
So wait, you're trying to create an appvar named VARXXXXX where XXXXX is a number?
Well, when you store something into a floating point variable, each nibble represents a digit.
They take the form:
Sign: $00=positive integer, $80 = negative
Decimal Point location: $80 = x10^0, $81 = x10^1, $7F=x10-1, etc
XX: first X is one digit, second X is another
Sign, DecLocation, XX,XX,XX,XX,XX,XX,XX
Ex: 15,540 would be
$00, $84, $15,$54,$0/\0,$00,$00,$00,$00
where the decimal would be.
I'm fairly certain that that is how the number would be stored in OP1/2/wherever it's stored, all you would need to do is skip the first two bytes of the OP1 register, load it into a, do AND $F0 to clear out the second digit, shift the bits over to the right, append that digit to your appvar name, reload that byte into a, AND $F to clear out the bits corresponding to the first digit, append that to your appvar name, and then go to the next byte and repeat.
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm
Yea, it will be a string. To the calculator it is a null-terminated string.
But yea, take the value from the OP register, convert it to an ascii string ($30?) then load it into the offset in the name (var_name+4 + offset in the OP register). But remember, the OP register stores the digits by nibble (4 bits), so for the leftmost nibble, you'll have to shift it to the right (srl should work, I believe). If you use a shift that loads the carry into the 7th bit, be sure to make sure it isn't set.
But yea, take the value from the OP register, convert it to an ascii string ($30?) then load it into the offset in the name (var_name+4 + offset in the OP register). But remember, the OP register stores the digits by nibble (4 bits), so for the leftmost nibble, you'll have to shift it to the right (srl should work, I believe). If you use a shift that loads the carry into the 7th bit, be sure to make sure it isn't set.
-
- Calc King
- Posts: 1513
- Joined: Sat 05 Aug, 2006 7:22 am
yes $30 equals the large font 0 (zero)
that OP thing is a very good plan so i'll just mess around with the code untill it works, the newst problem however is unfortunately with the read/write functions..
edt: the routine works almost perfect, except that a number multiplied by 10^n will result in the same name, eg 4, 40, 400, 4000 and 40000 will be the same name, i think it can be solved by starting at the end, am i right?
that OP thing is a very good plan so i'll just mess around with the code untill it works, the newst problem however is unfortunately with the read/write functions..
edt: the routine works almost perfect, except that a number multiplied by 10^n will result in the same name, eg 4, 40, 400, 4000 and 40000 will be the same name, i think it can be solved by starting at the end, am i right?
-
- Extreme Poster
- Posts: 340
- Joined: Fri 07 Jul, 2006 2:39 pm