Re: A83: Re: Re: Why don't it work


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

Re: A83: Re: Re: Why don't it work




it doesnt work like that.  Each byte (a single register is one byte) 
contains 8 bits, giving the byte a value from 0-255, so if within de, d=1, 
e=0,  de=256.  if it were d=0,e=1, de=1.  The relationship between the two 
is basically an extension of the second register in the pair, e.  so if d=1 
(%00000001), and e=31 (%00011111), de = 256+35=291, 
(%0000000100011111).  However, when you extract data from memory into a 
register pair, the order is reversed.
ie.
  ld hl,(data)

data: .db 0,1           ; data byte is 8 bit data

this would load 0 into register l, and 1 into register h.  so hl = 256

however, the following code would correctly load 5 into hl

  ld hl,(data)

data: .dw 5             ; data word is 16 bit data

i hope that solves any problems with understanding register pairs.

-harper



At 10:27 AM 8/28/00 -0400, you wrote:

>If d is 0 and e is 5, when I load de, will I get 5 or 50? Im not sure if 
>the deal with reversing bytes in memory will mess this up.
>
>  Colin
>




References: