[TI ASM] storing data

Got questions? Got answers? Go here for both.

Moderator: MaxCoderz Staff

chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

Is there a space in front of the instruction?
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

if tabs count (they should, i have no aligning trouble with tabs)
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

Yea, tabs count. Are you doing:
ld hl,OP1+1
ld a,(hl)
?
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

yes this:
ld ix,OP1+2
ld hl,OP1+1
ld a,(hl)
since you told me to, didnt you?
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

Yea, and it still gives you an error there? I don't see any invalid instructions...
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

yes still does
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

Try getting rid of ld hl,OP1+1 and replacing ld a,(hl) with ld a,(ix-1)
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

c:\asm\source\appvar.z80 line 0127: Label not found: (a)
c:\asm\source\appvar.z80 line 0127: Unknown token: (,)
c:\asm\source\appvar.z80 line 0127: Unknown token.

still :(
lets just blame tasm
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

Post your source real quick... Maybe there's something around there that's causing a problem.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

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
sorry im late, my internet (casema cable) is having some problems today
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

It's alright. I figured out the issue. I typed sub a,$7F. It should just be sub $7F :oops:

It should compile perfectly now.

EDIT: The sub a,$7f comes right after the ld a,(ix-1). Let me know of any errors in the code I gave you now (after all those errors! sorry!) and I'll try to spruce it up for you. Hope it works :)
Last edited by chickendude on Tue 08 Aug, 2006 8:22 pm, edited 1 time in total.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

oh yea omg i should have seen that.. oh well we all make mistakes i guess
it works now
note that im using a 9 byte thing for a 1 byte value, ive been experimenting with mov9toop1 and stuff because it doesnt store or read the integer properly
(i cant know which it doesnt do, because i need atleast 1 working to test the other)
Last edited by King Harold on Tue 08 Aug, 2006 8:27 pm, edited 1 time in total.
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

Haha, sorry about that one.
King Harold
Calc King
Posts: 1513
Joined: Sat 05 Aug, 2006 7:22 am

Post by King Harold »

dont worry, it compiles, but work.. no :(
if the input value is 1 it makes "Var11" in any other case it crashes
chickendude
Extreme Poster
Posts: 340
Joined: Fri 07 Jul, 2006 2:39 pm

Post by chickendude »

Hmm...that's with the new one I loaded? Did the old one function correctly? (aside from the zero issue)

I might have to look at it at home where I can test it out on the emulator. The only thing that is really different from the other one I gave you (that appended the 0s) is the ld a,(ix-1) part. That's all that I can really think of that would have issues, that it's loading a number other than what I expect it is.

Try adding this code:
;DISPLAY A
bcall(_homeup)
ld l,a
bcall(_dispHL)
bcall(_getkey)
ret

to see what number is displayed. If the number corresponds to the number of numbers (ex: 3 for the number 553 or 4 for # 2253).

Try messing around with it til it's right. But i've gotta go now. I'll check back later tonight.
Post Reply