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