.list
#define equ .equ
#define EQU .equ
#define end .end
#include ti83plus.inc
.nolist
#define bcall(label) RST 28h \ .dw label

        .org    $9D93
        .db     $BB,$6D

begin:
 bcall(_ZeroOP1)	; Reset OP1.
 ld	a,tans		; Load the Ans token (tAns).
 ld	(op1+1),a		
 bcall(_rclvarsym)	; Look it up.
 ld     hl,op1
 ld     (hl),6
 ex     de,hl
 ld     a,(hl)
 ld     b,0
 ld     c,a             ;bc= length of ans now
 inc	hl
 inc	hl
 ld	de,op1+1
 ldir
 ex	de,hl
 ld	(hl),0
 bcall(_chkfindsym)
 ret	c		;not found

 xor	a
 cp	b
 jr	z,inram

;check if we can put this in ram
 push	de
 ld	de,-6
 add	hl,de
 ld	a,(hl)		;find length of name
 add	a,10		;and calculate header's length
 ld	b,a
 inc	hl
 ld	a,(hl)		;a=flash page
 ld	h,0
 ld	l,b		
 pop	de
 add	hl,de		;hl=flash offset
 ld	de,8265h	;de=where to put data
 ld	bc,2		;bc=number of bytes
 push	hl
 push	af
 bcall(_FlashToRam)
 ld	hl,(8265h)
 ex	de,hl
 bcall(_MemChk)
 push	de
 or	a
 sbc	hl,de
 jr	c,quit		;not enough ram
;load into ram
 ld	de,($9820)
 pop	bc
 pop	af
 pop	hl
 push	de
 bcall(_FlashToRam)
 pop    de	
 
inram:
 ex	de,hl
 ld	e,(hl)
 inc	hl
 ld	d,(hl)
 inc	hl
 di           
 ld   a, 0FDh
 out  (01h), a  

main:
 ld   a, (hl) 
 and  0Fh
 ld   c, a    
 call Label15
 ld   a, (hl) 
 srl  a       
 srl  a       
 srl  a       
 srl  a       
 and  0Fh
 ld   c, a
 push iy
 pop  iy 	;slow this down a little
 call Label15
 inc  hl      
 dec  de      
 ld   a, d    
 push iy	;slow this down a little
 pop  iy
 or   e       
 jr   nz,main
 ei         
 ret 
         
quit:
 pop af
 pop af		 ;fix the stack
 pop af
 ret

Label15:
 ld   b, c    
 inc  b       
 ld   a, 0D3h

Label18:
 out  (00h), a  
 djnz Label18
 ld   a, 10h
 sub  c       
 ld   b, a    
 ld   a, 0D0h

Label19:
 out  (00h), a  
 djnz Label19
 ret
.end
END