Re: A83: String output and operations


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

Re: A83: String output and operations






--- Jkhum98@aol.com wrote:
> 
> In a message dated 12/11/99 1:23:55 PM Central
> Standard Time, 
> clarinetlord@yahoo.com writes:
> 
> >  How do I make system strings (Str1-Str0) in asm?
> I
> >  also want to do operations on the strings, like
> adding
> >  and extracting subsets. In other words, the
> equivelant
> >  of a basic program like this:
> >  
> >  :"E"->Str1
> >  :"0123456789ABCDEF"->Str2
> >  :Sub(Str2,4,1)+Str1->Str1
> >  :Disp Str1
> >  (Output: 3E)
> >  
> >  Is this possible to do, or is there somthing
> different
> >  I could use that would be faster smaller, etc.
> >  
> >  =====
> >  Cyrus Collier, clarinet lord.
> >  a.k.a. "The Virus"
> 
> It is better to avoid using OS Variables for stuff
> like this. Instead just 
> use byte arrays of data that represents string data
> for you. To do that, you 
> would have a Label with a ".db" statment, and your
> values following it, then 
> a terminating '0' like so...
> 
> String1:
>     .db "E",0
> String2:
>     .db "0123456789ABCDEF",0
> String3:
>     .db 0,0,0,0,0,0,0,0,0,0
> 
> I whipped up a routine for substring manipulation:
> 
> Substring_Copy:
> ; Input: HL -> Source String, DE -> Destination
> String  
> ;   B = Position in Source String to Start, C = # of
> Bytes to Copy
>     dec b
>     jr z, Now_Copy_String
> Find_Start_Loop:
>     inc hl
>     DJNZ Find_Start_Loop
> Now_Copy_String:
>     ld b, 0
>     LDIR
>     ld (de), 0
>     ret
>     
> Here is an example on how to use that...
> 
>     ld hl, String2
>     ld de, String3
>     ld bc, 4*256+5
>     call Substring_Copy
> 
> and after that sequence, the memory at the label
> 'String3' will look like 
> this:
> 
> String3:
>     .db "34567",0,0,0,0,0
> 
> I suggest that you not put your destination string
> directly in your program 
> though, incase you accidentally overwrite some data
> later past the string. 
> You should put it in Ram instead, and give yourself
> enough room to work with 
> like so:
> 
> #define     TempString  Savesscreen+0
> #define     NextVar     Savesscreen+25
> 
> And that will open up 25 bytes to store your string
> data. To display the 
> string, you would use the _puts or _vputs romcalls.
> You can learn about how 
> to do that in the AsmGuru tutorial set or any other
> tutorial out there. I 
> hope I could have been of help, cya...
> 
> Jason_K
> 
> 
Thanks for the tip, but the reason I want to use
system strings is because the string needs to be
accessible outside of the asm program. You can store
OP1 values into system variables, like "W", but I
don't know if it can be done with strings also.


=====
Cyrus Collier, clarinet lord.
a.k.a. "The Virus"

__________________________________________________
Do You Yahoo!?
Thousands of Stores.  Millions of Products.  All in one place.
Yahoo! Shopping: http://shopping.yahoo.com


Follow-Ups: