Re: A83: please review my code


[Prev][Next][Index][Thread]

Re: A83: please review my code




See below.  Basically, you use way to many calls where you should use
jr's instead.  your prog is all screwed up.  You don't need ANY of the
calls in this program except for the ROM calls.  Don't use a call unless
it points to a subroutine that you use AT LEAST twice. 

>hi,
>can anyone please tell me what's wrong with my following code?  it
>starts looping and when i press clear the calculator shuts down and
>freezes.  please email me as soon as possible.  thank you.
>sincerely,
>sumit.
>
>the code is:
>
>.NOLIST
>#define equ .equ
>#define EQU .equ
>#define end .end
>#include "ti83asm.inc"
>#include "tokens.inc"
>.LIST
>text_mem = savesscreen
>graph_mem = plotsscreen
>xcoor = text_mem
>ycoor = text_mem + 1
>.org 9327h
>	call _runIndicOff
>	call _clrLCDFull
>	call _grbufclr
>	ld hl,0
>	ld (xcoor),hl
>	ld hl,0
>	ld (ycoor),hl
>	ld hl,title
>	ld de,plotsscreen
>	ld bc,$300
>	ldir
>	call  _grbufcpy_v
>	call mainloop
>	ret
>mainloop:
>	ld a,0ffh
>	out (1),a
>	ld a,0fdh
>	out (1),a
>	in a,(1)
>	cp 191
>	call start

Should be "call	z,Start" , unless you want to call start automatically,
no matter what key is presses

>	jp nz,mainloop

Jr would be one less byte; program will get stuck here after it calls
start

>smallloop:
>	ld a,0ffh
>	out (1),a
>	ld a,0fdh
>	out (1),a
>	in a,(1)
>	cp 191
>	call quit

this should be a "jr	z,Quit"

>	jp nz,smallloop

Jr would be one less byte

>quit:
>	call _clrLCDFull
>	ret

Ret will return to the end of the Start area, not exit the program

>start:
>	call _clrLCDFull
>	call _grbufclr
>	SET textinverse,(iy+textflags)
>	call _homeup
>	ld hl,bare1
>	call _puts
>	RES textinverse,(iy+textflags)
>	ld hl,0102h
>	ld (CURROW),hl
>	ld hl,bare2
>	call _puts
>	ld hl,0104h
>	ld (CURROW),hl
>	ld hl,bare3
>	call _puts
>	ld hl,0106h
>	ld (CURROW),hl
>	ld hl,bare4
>	call _puts
>	call smallloop

This should be a "jr smallloop"

No ret here.  It will try to run your strings below.  You NEED a ret here

>bare1:
>	.db "Your Choice is:",0
>bare2:
>	.db "1. English Sys",0
>bare3:
>	.db "2. Length/Area",0
>bare4:
>	.db "3. Weight/Cap.",0
>title:
>    	.db    
>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
>    	.db    
>0,0,0,0,0,3,248,0,0,0,0,0,0,0,0,0,0,6,56,0,0,0,0,0,0,0,0,0,0,8,240
>    	.db    
>124,32,9,223,140,1,207,31,8,0,17,240,194,51,181,51,147,130,81,48,140,224
,17,1,185,44,150,83,22,66,209
>    	.db    
>110,75,32,16,249,41,32,138,81,144,66,145,74,72,32,16,9,57,72,140,149,145
,132,145,78,82,32,8,13,3,84
>    	.db    
>134,151,38,152,145,64,213,32,4,60,134,51,3,16,186,145,31,33,140,192,3,24
0,124,1,1,31,139,143,14,31,0
>    	.db    
>64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
>    	.db    
>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
>    	.db    
>0,0,0,0,240,240,0,0,0,0,0,0,0,0,0,1,141,8,0,0,0,0,0,0,0,0,0,1,101,196,0
>    	.db    
>0,0,0,0,0,0,0,0,1,100,196,0,0,0,0,0,0,0,0,0,1,105,12,0,0,0,0,0,0,0,0
>    	.db    
>0,3,244,226,0,0,0,0,0,0,0,0,0,2,100,226,0,0,0,0,0,0,0,0,0,2,5,2,0,0,0
>    	.db    
>0,0,0,0,0,0,1,13,6,0,0,0,0,0,0,0,0,0,0,241,248,0,0,0,0,0,0,0,0,0,0
>    	.db    
>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
>    	.db    
>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0,0,16,0
>    	.db    
>0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0
>    	.db    
>0,0,0,62,64,0,0,0,0,0,0,0,0,0,0,39,64,0,0,0,0,0,0,0,0,0,0,69,64,0,0
>    	.db    
>0,0,0,0,0,0,0,0,73,128,0,0,0,0,0,0,0,0,0,0,113,128,0,0,0,0,0,0,0,0,0
>    	.db    
>0,1,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0
>    	.db    
>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
>    	.db    
>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,0,0,0,0,0,0,0,0,0,0,0
>    	.db    
>65,0,0,0,0,240,0,0,0,0,0,0,73,124,131,14,1,136,3,111,140,243,0,0,71,197,
125,241,1,39,255
>    	.db    
>179,243,13,128,0,97,22,76,129,1,102,18,210,99,4,128,0,113,150,12,231,1,7
0,82,208,233,36,128,0,220,150
>    	.db    
>4,164,3,2,81,144,225,4,128,0,128,132,246,164,2,114,82,146,205,44,128,0,7
3,132,246,164,2,82,18,146,77
>    	.db    
>164,128,0,62,127,159,188,3,223,255,255,255,255,128,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0
>    	.db    
>0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
>    	.db     0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
>.end
>END
>_________________________________________________________
>DO YOU YAHOO!?
>Get your free @yahoo.com address at http://mail.yahoo.com
>
>

_____________________________________________________________________
You don't need to buy Internet access to use free Internet e-mail.
Get completely free e-mail from Juno at http://www.juno.com
Or call Juno at (800) 654-JUNO [654-5866]