Re: A86: more info needed on ld command


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

Re: A86: more info needed on ld command



Butler Family wrote:

> > ld (hl),nn  loads nn into the memory location whose
> >             address is stored in hl
>
> what is the use of loading it into the memory location if u can do the
>
> basically same thing w/o parentheses? or would it keep the hl from
> moving its location in the memory?and one last question what would it
> do
> if u did ld nn,(hl)? would it make nn equal to the memory location or
> save it as hl and have be where hl was?
>
> thanx again
>     Patrick

I think you miss understood what Dan said. If you did this:
  ld hl,$FC00
  ld (hl),nn
you would load the value of nn into memory location $FC00
hl would still be $FC00, but at memory location $FC00 you would have
copied the value of nn

if you do this:
  ld hl,$FC00
  ld hl,nn
then hl now equals nn and mem. location $FC00 was not changed.

now the second part of your question....
  ld hl,$FC00
  ld a,(hl)
this would put the value found at mem location $FC00 into the register a

hope that helps a little..

if you know anything about other languages (c,c++,pascal,..)  you can
think of (hl) as a pointer to the mem location that it's value is.

--
Trent Lillehaugen
Computer Engineering Major
California Polytechnic University, San Luis Obispo
<tllilleh@polymail.calpoly.edu>



References: