I guess this is the wrong place for this topic, but I couldn't find another one...

Well whats my problem:
I need a routine that takes a number as input and gives me the corresponding entry in the TI-83+'s catalog (that command list acessed via 2nd+0) as a string with the first character being the token and the rest being a string of characters that form the token. It does not need to have error handling, I can do it in basic by myself (Shouldn't be hard Razz)
Since I do not know any Asm I have no idea how to do this and I hope that someone could help me.

I am gping to use this program in combination with Basic so if possible please compile to Hex code...
Thanks to any help!
You could do at least part of this in pure TI-BASIC:
1) Put each token in the Catalog in a string in your program, along the lines of "abs( and angle(ANOVA(AnsArchive Asm(AsmComp(...".
2) Use the sub command to pick the Nth item from it: sub("abs( and angle(ANOVA(AnsArchive Asm(AsmComp(...",X,1)
3) Now you'll have the Nth token from the catalog in the Ans string; you could store it to a string variable (Str1 to Str0) and/or give it to an assembly program that could run _Get_Tok_Strng.
KermMartian wrote:
You could do at least part of this in pure TI-BASIC:
1) Put each token in the Catalog in a string in your program, along the lines of "abs( and angle(ANOVA(AnsArchive Asm(AsmComp(...".
2) Use the sub command to pick the Nth item from it: sub("abs( and angle(ANOVA(AnsArchive Asm(AsmComp(...",X,1)
3) Now you'll have the Nth token from the catalog in the Ans string; you could store it to a string variable (Str1 to Str0) and/or give it to an assembly program that could run _Get_Tok_Strng.


I was storing the tokens and their character strings like this before but it uses up around 4.5 kB of RAM and I can't afford that. But thanks for the reply!
KermMartian wrote:
You could do at least part of this in pure TI-BASIC:
1) Put each token in the Catalog in a string in your program, along the lines of "abs( and angle(ANOVA(AnsArchive Asm(AsmComp(...".
2) Use the sub command to pick the Nth item from it: sub("abs( and angle(ANOVA(AnsArchive Asm(AsmComp(...",X,1)
3) Now you'll have the Nth token from the catalog in the Ans string; you could store it to a string variable (Str1 to Str0) and/or give it to an assembly program that could run _Get_Tok_Strng.


I was storing the tokens and their character strings like this before but it uses up around 4.5 kB of RAM and I can't afford that. But thanks for the reply!
Nik wrote:
KermMartian wrote:
You could do at least part of this in pure TI-BASIC:
1) Put each token in the Catalog in a string in your program, along the lines of "abs( and angle(ANOVA(AnsArchive Asm(AsmComp(...".
2) Use the sub command to pick the Nth item from it: sub("abs( and angle(ANOVA(AnsArchive Asm(AsmComp(...",X,1)
3) Now you'll have the Nth token from the catalog in the Ans string; you could store it to a string variable (Str1 to Str0) and/or give it to an assembly program that could run _Get_Tok_Strng.


I was storing the tokens and their character strings like this before but it uses up around 4.5 kB of RAM and I can't afford that. But thanks for the reply!
Why so big? You just need to put the tokens, and there definitely aren't 4500 tokens... This string should only be a few hundred elements long, I don't know how many tokens there are, but probably about 400? this string should stay under 1kb... then running a small ASM program like Kerm said would return (with the help of some pretty simple Basic manipulation) the Nth token in Ans.
mr womp womp wrote:
Nik wrote:
KermMartian wrote:
You could do at least part of this in pure TI-BASIC:
1) Put each token in the Catalog in a string in your program, along the lines of "abs( and angle(ANOVA(AnsArchive Asm(AsmComp(...".
2) Use the sub command to pick the Nth item from it: sub("abs( and angle(ANOVA(AnsArchive Asm(AsmComp(...",X,1)
3) Now you'll have the Nth token from the catalog in the Ans string; you could store it to a string variable (Str1 to Str0) and/or give it to an assembly program that could run _Get_Tok_Strng.


I was storing the tokens and their character strings like this before but it uses up around 4.5 kB of RAM and I can't afford that. But thanks for the reply!
Why so big? You just need to put the tokens, and there definitely aren't 4500 tokens... This string should only be a few hundred elements long, I don't know how many tokens there are, but probably about 400? this string should stay under 1kb... then running a small ASM program like Kerm said would return (with the help of some pretty simple Basic manipulation) the Nth token in Ans.


In any case I would need an assembly program for getting the characters of a token. And since I will need an assembly program anyways it would save me a few hundrets of bytes to make it get the actual token too instead of handling it with basic...
I believe the token getting part, the character breakdown part and the communication handling part wont take up more than 50 bytes each (=150b in total) making it significantly smaller than any basic attempt to do this...
Nik wrote:
I was storing the tokens and their character strings like this before but it uses up around 4.5 kB of RAM and I can't afford that. But thanks for the reply!
As repeated by mr womp womp, I'm suggesting storing a string of just the tokens, not the tokens plus their string equivalents. Using the BCALL that I suggested in my post, you can get the string equivalents from the tokens, while that token string will take on the order of ~700-800 bytes.

Nik wrote:
In any case I would need an assembly program for getting the characters of a token. And since I will need an assembly program anyways it would save me a few hundrets of bytes to make it get the actual token too instead of handling it with basic...
We don't know where the Catalog's token list is stored, so unless you can find it, you would have to still list all the tokens in the ASM program (at the cost of the exact same amount of space as listing them in the BASIC program).
KermMartian wrote:
We don't know where the Catalog's token list is stored, so unless you can find it, you would have to still list all the tokens in the ASM program (at the cost of the exact same amount of space as listing them in the BASIC program).


Shouldn't this be a relatively straightforward thing to discover with a bit of emulator?
elfprince13 wrote:
KermMartian wrote:
We don't know where the Catalog's token list is stored, so unless you can find it, you would have to still list all the tokens in the ASM program (at the cost of the exact same amount of space as listing them in the BASIC program).


Shouldn't this be a relatively straightforward thing to discover with a bit of emulator?
It's likely to vary in every OS version, since we don't know of a call that returns a pointer to that list. But again, with a bit of sleuthing, we could see (1) if and where there's such a list (2) if there's a cross-OS-version way to get a pointer to that list.
I thought of pointing to the list...

And I believe it wont be that hard to find it:
Using some search engine to browse the rom for the first ten tokens or so... This should give a really accurate result, and if you failed and it wasn't the catalog just let the search algorithm do it's work further. I think you will find it within 10 minutes with that method. My OS version is 1.19 and currently I am really not going to release my program to the public. (Well at least not to anyone but my classmates who have the exact same calcs).
If I will want to release it one time I will ask to update it to make an OS check and then use the predefined pointers corresponding to that OS.
Okay, I suspect this won't work on all calculators. Wikiti says that OS 1.16 has the table on page 7, my calc (OS 2.55) has it on page 1. Without searching through the pages, I don't know what it will be, so I hardcoded it for now.


You wanted the hexadecimal opcode, right? Good luck...

Code:

;;check if hook is set already, if not set it, if yes, check for the needed data
FDCB365E
2828
2A0080
7CB5283A
22A39D
ED5B0280
ED52
22AC9D
210000
220080
220280
EF4750
21249E
3E06
EF3C4C
C9

;;setup the hook
21E39D
117298
011000
79
D5
EDB0
E1
ED430080
ED430280
EF4450
21F39D
EF0A45
C9

;;hook code, just gets the start and end of the table to 8000h and 8002h
83
FE052003220080
FE06C0
ED530280
C9

;;this is the message displayed
4F70656E2074686520636174616C6F675468656E2072756E207468697320202070726F67
72616D20616761696E2E202000


;;Program data. First part is the name in hexadecimal ASCII. Terminate with 00.
434154454C454D00

8A00
BB6D
EFD74A
E61FC0
EFEF4A
210000
B2
2862
1B
CB23CB12
19
3852
210000
3E01      <--- this loads flash page 01. if it doesn't work, try 07 or others.
D306
19
7E
FEFD2001AF
C601DE01
4F23
7E
324684
280179
EF024A
3E07        ;<== reset the flash page to default (07 on my calcs)
D306
0E01
218F84
731415
28032D720C
0600
E5C5
3E07914F
C5
EF524BD7
3604
E1D51313EB
EF5743
E1C1D1
71237023
EB
EDB0
C9

;;"DNE" message
01030021019E18D6

;;Get the number of elements.
956F9F9467
CB3CCB1D
23
EF9247
EF5641
EFBF4A
C9

;;"DNE"
444E45

I am still optimizing it, and I plan to have a better version ready at some point.

Readme
Run the program.
Go to the catalog.
Run the program again.
Now a new program will be created called "CATELEM" and that is the program you want to use. It's functions are as follows:

If Ans=0, this program returns how many catalog entries there are (returned in Ans).
If Ans is a number greater than the number of catalog entries, "DNE" is returned ("Does Not Exist").
Otherwise, Ans contains the corresponding token.

So:
1:Asm(prgmCATELEM returns "abs("
2:Asm(prgmCATELEM returns " and "
9999:Asm(prgmCATELEM returns "DNE"

EDIT: For those who want the source code (slightly modified already):

Code:

_ConvKeyToTok=4A02h
;_Get_Tok_Strng=4594h
;_CreateTempString=4324h
_ExecuteNewProgram=4C3Ch
_PutS=450Ah
_RclAns=4AD7h
_ConvOP1=4AEFh
keyExtend=8446h
OP1=8478h
OP3=OP1+33
;_OP4ToOP1=4138h
_SetXXXXOP2=4792h
_OP2ToOP1=4156h
_StoAns=4ABFh

#define bcall(x) rst 28h \ .dw x
.db $BB,$6D
.org $9D95
SetUpCatalogElement:
    bit 3,(iy+36h)
    jr z,setuphook
    ld hl,(8000h)
    ld a,h
    or l
    jr z,directions
    ld (tablestart),hl
    ld de,(8002h)
    sbc hl,de
    ld (tablesize),hl
    ld hl,0
    ld (8000h),hl
    ld (8002h),hl
    bcall(5047h)   ;disablehook
;    bcall(4F90h)   ;disablehook
    ld hl,progname
    ld a,6
    bcall(_ExecuteNewProgram)
    ret
setuphook:
    ld hl,hook
    ld de,9872h
    ld bc,hookend-hook
    ld a,c
    push de
    ldir
    pop hl
    ld (8000h),bc
    ld (8002h),bc
    bcall(5044h)     ;enable catalog1 hook
;    bcall(4F8Dh)     ;enable catalog2 hook
directions:
    ld hl,help
    bcall(_PutS)
    ret
hook:
    .db 83h
    cp 5
    jr nz,$+5
    ld (8000h),hl
    cp 6
    ret nz
    ld (8002h),de
    ret
hookend:
progname:
  .db "CATELEM",0
  .dw progend-progstart
progstart:
    .db $BB,$6D
    bcall(_RclAns)
    and $1F
    ret nz
    bcall(_ConvOP1)
tablesize =$+1
    ld hl,0
    or d
    jr z,returnsize
    dec de
    sla e
    rl d
    add hl,de
    jr c,dne
tablestart=$+1
    ld hl,0
    ld a,1
    out (6),a
    add hl,de
    ld a,(hl)
;FF=>FE, FD=>0
    cp $FD
    jr nz,$+3
    xor a
    add a,1
    sbc a,1
    ld c,a
    inc hl
    ld a,(hl)
    ld (keyExtend),a
    jr z,$+3
    ld a,c
    bcall(_ConvKeyToTok)
    ld a,7
    out (6),a
    ld c,1
    ld hl,OP3+1
    ld (hl),e
    inc d
    dec d
    jr z,$+5
    dec l
    ld (hl),d
    inc c
outstr:
    ld b,0
    push hl
    push bc
    ld a,7
    sub c
    ld c,a
    push bc
    bcall(4B52h)    ;AnsName
    rst 10h
    ld (hl),4
    pop hl
    push de
    inc de   
    inc de
    ex de,hl
    bcall(4357h)    ;delmem
    pop hl
    pop bc
    pop de
    ld (hl),c
    inc hl
    ld (hl),b
    inc hl
    ex de,hl
    ldir
    ret
dne:
    ld c,3
    ld hl,s_dne
    jr outstr
returnsize:
    sub l
    ld l,a
    sbc a,a
    sub h
    ld h,a
    srl h
    rr l
    inc hl
    bcall(_SetXXXXOP2)
    bcall(_OP2ToOP1)
stoans:
    bcall(_StoAns)
    ret
s_dne=$-progstart+$9D93
.db "DNE"
progend:
help:
  .db "Open the catalog"
  .db "Then run this   "
  .db "program again.  ",0
.echo "setup:",$-$9D95
.echo "catelem:",progend-progstart-2
Thats simply awesome...
But I believe I will crash my calculator if I would attempt to retype this. Is it possible to convert this to *.8xp somehow?
Nik wrote:
Thats simply awesome...
But I believe I will crash my calculator if I would attempt to retype this. Is it possible to convert this to *.8xp somehow?


This is assembly, the easy way it's written out. You have to have a specific setup to build an ASM program, which is explained here: Learn 83+ Assembly in 28 Days. That resource is also the best place to start if you want to learn how to program in assembly yourself.
prgmCESETUP
CESETUP Source

I modified the program, so all you have to do is run Asm(prgmCESETUP) and that will create prgmCATELEM. After this, you can delete prgmCESETUP if you want.


There are potential issues! I advise archiving or otherwise backing up your programs before running them to test.

If you run prgmCESETUP and it exits without crashing, let me know.
Next I would like you to run 0:Asm(prgmCATELEM):Ans. This returns the catalog size. If this value is absurd, let me know-- my calc returns 368 and yours will be different.
1. Run, ran on Wabbitemu Emulator:
Asm(prgmCESETUP

Took about 1/2 second, then exited the program, no done was displayed. Program CATELEM was created.

0:Asm(prgmCESETUP took almost no time, returned 19950.

prgmTEST
:0-> A
:While 1
:A+1-> A
:Asm(CATELEM
:Disp Ans
:Ans-> Str1
:End

Runs slowly, but seems to display the correct tokens most of the time. At some places it displayed something that didn't belong there, after browsing through the catalog started displaying random tokens. I stopped it at A> 500.
Okay, this isn't so bad, though I am concerned about Done not being displayed.

Hopefully I find a better way to figure out the table size, but until then, I hope this helps!

I have an idea about how to fix the problem, but it is going to be annoying. I don't think there is much I can do for fixing the problem of speed. My code is optimized, but I have to rely on the OS for some stuff.
Okay... I am sorry for my load of questions but I still need something that allows me to convert a token into a string of characters... I downloaded the TokenASCII program fromm ticalc.org but it only converts uppercase letters correctly - the rest show up as some random characters and testing if they are the characters they should be also returns 0:

"sin(":Asm(prgmTOKASCII
Ans
Fix Float>=fMax(
sub(Ans,1,1)="s
0
Oh, I was worried that might be the case. Here, try this:
tok2chars.8xp
tok2chars.z80
It only properly converts uppercase, lowercase, space, and "(" so that will get most of the chars. I'll have to work a lot more in order to get it to work for all of them.
Xeda, you are awesome. Simply awesome. Thank you so much!
Here is the finalized program for Catelem: Catelem.zip

It is all one program (no more setup program). Run it once, it sets up OS-specific info and then it removes its own setup code. After this, it can be used as previously described. Readme and source are included.

It is much faster searching for the catalog table. I tested a few OSes from 1.03 to 2.55MP and found that the catalog was on page 7 for the TI-83+ and page 1 for the TI-84+, so this significantly reduces the search time.

I also properly searched for the table size and I also sped up that code a whole bunch.

After setup, the program seems to run much faster than before, and I have no idea why.
  
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 1 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