Posted: Tue 08 Aug, 2006 5:53 pm
Is there a space in front of the instruction?
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
dec a
JP Z,read_int
dec a
JP Z,put_char
dec a
JP Z,read_char
ret
create_var: ;-------------------------------------------------------------------------
bcall(_RclAns) ;rcl ans because its lost
ld hl, 2 ;2nd list element (name)
bcall(_GetLtoOp1) ;put it in op1
call name_loop
bcall(_RclAns) ;ans gets lost somewhere..
ld hl, 3 ;3rd list element (size)
bcall(_GetLtoOp1) ;put it in op1
bcall(_ConvOp1) ;store the hex value in de
push de ;push de because it gets destructed
ld hl, var_name ;load the name
bcall(_Mov9toop1) ;moves the name to OP1
bcall(_ChkFindSym) ;see if it needs to be deleted
JR C, create_var_2 ;jump if it doesnt exist
JP err_code_1 ;jump if exists
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
call name_loop
ld hl, var_name ;load the name
bcall(_Mov9ToOP1) ;name in op1
bcall(_ChkFindSym) ;check if it exists, cant delete non-existant things
JP C, err_code_1 ;if not found, dont delete
bcall(_DelVar) ;else delete
xor a ;0 in a
bcall(_SetxxOP1) ;0 in op1
bcall(_StoX) ;op1 in x (tell user that the appvar has (probebly) been deleted
ret
put_int: ;--------------------------------------------------------------------------
bcall(_RclAns) ;rcl ans because its lost
ld hl, 2 ;2nd list element (name)
bcall(_GetLtoOp1) ;put it in op1
call name_loop
bcall(_RclAns) ;ans gets lost somewhere..
ld hl, 3 ;3rd list element (offset)
bcall(_GetLtoOp1) ;put it in op1
bcall(_ConvOp1) ;store the hex value in de
push de ;push de to stack
bcall(_RclAns)
ld hl, 4 ;recall the 4th element (value)
bcall(_GetLtoOp1)
bcall(_ConvOp1) ;put the LSB in a
ld hl, var_int ;we're going to store a in var_int so first load the pointer
ld (hl),a ;save a to var_int
ld hl, var_name ;load the name
bcall(_Mov9toop1) ;moves the name to OP1
bcall(_ChkFindSym) ;see if it needs to be deleted
JP C, err_code_1 ;jump if it doesnt exist
ld a, b ;load rom page in a
or a ;compare a = 0
JR Z, put_int_2 ;rom page 0 means var is in ram, so dont change archive state
bcall(_Arc_Unarc) ;rom page =! 0 so change Archived state
put_int_2:
bcall(_EditProg) ;open edit session
pop hl ;data offset in hl
add hl, de ;de is pointer to begin of appvar, de is offset
ex de, hl ;put it in de for ldi
ld hl, var_int ;load pointer to var_int to hl for ldi
ldi ;actual saving
bcall(_CloseProg) ;close edit session
ret
read_int: ;----------------------------------------------------------------------------
bcall(_RclAns) ;rcl ans because its lost
ld hl, 2 ;2nd list element (name)
bcall(_GetLtoOp1) ;put it in op1
call name_loop
bcall(_RclAns) ;ans gets lost somewhere..
ld hl, 3 ;3rd list element (offset)
bcall(_GetLtoOp1) ;put it in op1
bcall(_ConvOp1) ;store the hex value in de
push de ;push de to stack
ld hl, var_name ;load the name
bcall(_Mov9toop1) ;moves the name to OP1
bcall(_ChkFindSym) ;see if it needs to be deleted
JR C, err_code_1 ;jump if it doesnt exist
ld a, b ;load rom page in a
or a ;compare a = 0
JR Z, read_int_2 ;rom page 0 means var is in ram, so dont change archive state
bcall(_Arc_Unarc) ;rom page =! 0 so change Archived state
read_int_2:
pop hl ;pop offset from stack
add hl, de ;add begin to offset
ld de, var_int ;load pointer to var_int
ldi ;move the data
dec de ;ldi inc's de so we dec it
ld a,(de) ;de points to var_int again
bcall(_SetxxOp1) ;put a in op1
bcall(_StoAns) ;store the byte in ans
ret
put_char: ;-----------------------------------------------------------------------------
ret
read_char: ;-----------------------------------------------------------------------------
ret
name_loop: ;-----------------------------------------------------------------------------
ld ix,OP1+2
ld a,(ix-1)
ld hl,var_name+4
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 ix
inc hl
djnz loop
exit:
ret
err_code_1: ;-------------------------------------------------------------------------------
ld a, 1 ;1 to a
bcall(_SetxxOp1) ;a to op1
bcall(_StoX) ;op1 to x (1 to x)
ret
var_name: ;-------------------------------------------------------------------------------
.db AppVarObj, "Var", $20, $20, $20, $20, $20, 0
var_int:
.db $00, $00, $00, $00, $00, $00, $00, $00, $00
.end
END