Re: A83: Strings
[Prev][Next][Index][Thread]
Re: A83: Strings
i said you could do this to avoid using the buffer:
>1) "buffer" is a safe mem area that you copy the string data to so you
>can add a 0 terminator. there are better ways to do this. for instance
>you could use _putc to draw it char by char, so you don't need to add a
>0 terminator.
well here is the improved program that does just that
zstring.z80:
.NOLIST
#define equ .equ
#define EQU .equ
#define end .end
#include "ti83asm.inc"
#include "tokens.inc"
.LIST
_errundefined .equ 467Bh
strngobj .equ 04h
.org 9327h
call _zerooop1 ; clear op1
ld hl,op1 ; load var name for Str1 into op1
ld (hl),strngobj ;
inc hl ;
ld (hl),tvarstrng ;
inc hl ;
ld (hl),tstr1 ;
call _chkfindsym ; look it up
jp c,_errundefined ; error if not found
push de ;
pop hl ; hl -> string address
call _ldhlind ; hl -> string size
push hl ;
pop bc ; bc -> string size
inc de ;
inc de ; de -> string data
sloop:
ld a,(de) ; get character
call _putc ; draw character
inc de ; next character
dec bc ; decrement counter
ld a,b ; see if bc is at 0
or c ;
jr nz,sloop ;
call _newline ; move to a new line
ret
.end
END
References: