A86: Re: Re: Re: Input (yes another input question)
[Prev][Next][Index][Thread]
A86: Re: Re: Re: Input (yes another input question)
Yeah, I could have meant that. ;-)
I'm too tired to program...
-----Original Message-----
From: Dux Gregis <assets@eden.rutgers.edu>
To: assembly-86@lists.ticalc.org <assembly-86@lists.ticalc.org>
Date: Saturday, October 03, 1998 8:21 PM
Subject: A86: Re: Re: Input (yes another input question)
>
>
>Do you mean ld (hl),a and ld (ix+x),a?
>
>
>>
>>Yeah, that's the basic idea of a hardwired string input routine. Though
>you
>>have to use a pointer to the string with indirection:
>>
>>KeyLoop:
>> ld hl,string ; point to string
>> call GET_KEY
>> ld (string),hl ; store to byte 0
>> inc hl ; next byte
>> call GET_KEY
>> ld (string),hl ; store to byte 1
>> inc hl ; next byte
>> ...
>> ld (hl),0 ; if you wanted to zero-terminate it
for
>>_puts or whatever
>> ; make sure there is an INC HL after
>>the last LD (string),HL though....
>>
>>Another way that would be more similiar to your method (yet slower) would
>be
>>this:
>>
>>KeyLoop:
>> ld ix,String ; point to string
>> call GET_KEY
>> ld (string+0),a ; save to byte 0
>> call GET_KEY
>> ld (string+1),a ; save to byte 1
>> ...
>> ld (string+2),a ; null terminate it (not necessary, but that's
>>how to do it)
>>
>>The differences in this is that HL is used as a pointer in the first one.
>>It advances through the string as the characters are entered. It ends up
>>pointing to the end of the string after the routine finishes. In the
>second
>>one, IX is used as a base pointer (or index pointer, which is why it is an
>>"index register") to the string. It always points to the base (start) of
>>the string. Using HL has it's advantages when you are just moving through
>>data in order, as in this example. It is faster than indexing
>instructions.
>>Index registers are better when data must be accessed in a random (but
>>predetermined) order. Self modifying code can be used with these
>>instructions to produce some very fast code, however. But if a structure
>is
>>being accessed in a non-sequential order only once, it should be
rearranged
>>so a pointer like HL could be used. Data should fit the program.
>>
>>Hope this rant helps...
>>
>>
>>-----Original Message-----
>>From: UnEven Software <uneven14@hotmail.com>
>>To: assembly-86@lists.ticalc.org <assembly-86@lists.ticalc.org>
>>Date: Saturday, October 03, 1998 7:21 PM
>>Subject: A86: Input (yes another input question)
>>
>>
>>>
>>>After what Dux just said about using .db to input I got to thinking. I
>>>was wondering would this code work for getting a 3 char string?
>>>
>>>
>>>
>>>KeyLoop:
>>> call GET_KEY
>>> ld string+1,a
>>> call GET_KEY
>>> ld string+2,a
>>> call GET_KEY
>>> ld string+3,a
>>>
>>>Other_Code:
>>> ......
>>>
>>>
>>>
>>>string:
>>> .db 0,0,0
>>>
>>>Wouldn't that work? Or am I just thinking in another programming
>>>language?
>>>
>>>Just curious,
>>>
>>>Matt
>>>
>>>______________________________________________________
>>>Get Your Private, Free Email at http://www.hotmail.com
>>