Re: A86: ASM: Explaining HL


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

Re: A86: ASM: Explaining HL



In a message dated 97-10-26 01:59:45 EDT, you write:

> 
>  Radojcsics@aol.com wrote:
>  > 
>  > I know you have probably had a million and 1 of these, but for the life
of 
> me
>  > i cant quite grasp the concept of how HL works.  I know its a flag and
all,
> 
>  > but could anyone explain it to me in regards to BASIC, instead of
memory?(
> An
>  > example always helps)
>  
>  hl isnt a flag, its a 16-bit register pair used in operations
>  ex:
>  you can load a 16 bit number into it
>  ld hl,$2342
>  or a string
>  ld hl,(string)
>  
>  string:
>   .db "string",0
>  
>  you can also use h and l alone
>  ld h,$23
>  ld l,$45
>  this way hl would be a 16 bit number when used together, but an 8bit
>  number when used alone
>  

Actually, when used as a string, you need to say this:

ld hl,string

because otherwise, it loads (string), which is "st", or $6463 (i think) into
HL.  Also, HL itself is not a string, it is a _pointer_ to a string, which
means that the value in HL is the _address_ of the string in memory.  An
example of this in BASIC would be the vector MEMORY and the number HL, which
points (sort of) to an element in MEMORY, like such:

[123,235,342,443,523,644,634,176,745,175,823,194] -> MEMORY
5 -> HL

MEMORY(HL) would then be 523, making HL a pseudo-pointer to 523 in that
vector.  Get the idea?

~Steve


Follow-Ups: