[A83] Re: (hl) and hl


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

[A83] Re: (hl) and hl




> The calculator is made up of thousands of bytes...
I couldn't help quoting this part. :)

Back to the question:

"hl" is a name of the register, i. e. a reference to the 
internal memory (a 16-bit part of it) of the CPU. On the 
other hand, "(hl)" is a reference to the HLth byte (8 
bits!) of the RAM.

Some examples:

 ld hl,5000     - loads 5000 into HL (a 16-bit value)
 ld (hl),50     - loads 50 into the HLth byte of the RAM
 ld a,(hl)      - loads the value of the HLth byte into A
                  (again, A is just another register)
 ld a,hl        - that's invalid, since the two registers
                  are of different sizes (8 vs. 16 bits)
 ld sp,hl       - loads the value of HL into SP

I hope that also helps. :)

PG



References: