A83: Re: Ld
[Prev][Next][Index][Thread]
A83: Re: Ld
----- Original Message -----
From: Marc Puts <marcputs@hetnet.nl>
> I use the following code. It seems like it's working,
> but there's one thing that I'm not sure about:
>
>   call _rclX
>   call _convop1
>   ex de,hl
>   ld a,hl
>
>   ...
>
>   cp 1
Here is an example of how the 16 bit registers work
-----------
hl is a 16 bit number, which means that it is an integer from 0-65535
a is an 8 bit number, which means that it is an integer from 0-255
...but HL is actually a combination of two 8 bit registers,
with H being the high bit and L being the low bit.
this means the following
if hl = 42
h=0
l=42
if hl = 255
h=0
l=255
if hl = 256
h=1
l=0
--------------
if you want to compare the FULL 16 bit register to a number then i suggest
you use the following rom call.
 call _rclX
 call _convop1
 ld hl,1          ; we dont need to do ex de,hl... that would waste space,
since we are checking equality
 call _cphlde     ; 16 bit compare of hl to de
 i hope it helps
-harper
Follow-Ups:
References:
- A83: Ld
 
- From: "Marc Puts" <marcputs@hetnet.nl>