A82: Re: Printing Strings


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

A82: Re: Printing Strings



 If you have a pointer to the current word (point to the first letter of the
word), it should be fairly easy. To find the beginning of a word you can use
the instructions CPIR and CPDR. So if HL points to the current word the
following code should find the next.

XOR A  ;A=0 (the char we want to find)
LD BC,$FFFF ;We want to keep searching till we find a zero
CPIR ; Find next 0
; HL now points to the next work so calling D_LZ_STR would display it

To goto the previus word you could do the following.

XOR A ;A=0
LD BC,$FFFF
DEC HL ;Point to last letter of previus word
DEC HL
CPDR ; Find previus 0
INC HL ; Goto first letter
INC HL
; HL now points to the previus word.

You would ofcourse have to add a check of wether you were at the
end/beginning of  list of word, so you do not pass the ends, but other wise
i think this code should work (i have not tested it, but it looks right).

Dines

-----Original Message-----
From: Matt Maurano <maurano@best.com>
To: Assembly-82 Submition <assembly-82@lists.ticalc.org>
Date: 19. september 1997 04:41
Subject: A82: Printing Strings



>I want to be able to print a large number of strings stored in one
>location, but separately. For example, lets say I was doing a
>dictionary. I would want to be able to show each word on the screen, as
>the user  cycles through by the arrows. Example, it starts out on Cat,
>and when you press the right arrow, it goes to Dog, or the left would
>make it go to Bat. Now, I could do this by having separate code for all
>of the words, but that could get huge. I think this might be better:
>
>Dict:
>.db "Bat",0,"Cat",0,"Dog"
>
>And have it keep the location of the string its on, and go back or
>forward till it hits a zero, or some other delimiter. So I guess I'm
>asking, how do I print items of a zero-delimited database one at a time?
>No special sorting, just print them in the order stored. The code should
>actually be pretty short (Read to a zero, inc the location one, and
>print it), leaving the bulk of the space for the data, but I don't have
>the knowledge to do it. Any help?
>
>