[A83] Re: How using and
[Prev][Next][Index][Thread]
[A83] Re: How using and
The logical operation AND works like this:
Source | Mask | Result:
-------+-------+--------
0 | 0 | 0
1 | 0 | 0
0 | 1 | 0
1 | 1 | 1
AND performs the logical operation AND on each bit of the byte:
10101010 and 11110000 = 10100000
You can't do AND DE, because DE is 2 bytes long, not 1, but you can do AND
E, which ANDs A with E. (D is ignored)
Also, the instruction AND A does the same thing as CP 0 (so does OR A)
If you really need to do a 16-bit AND, then you should put the variable into
HL, then put the mask into de, then:
;HL = HL AND DE
ld a,l
and e
ld l,a
ld a,h
and d
ld h,a
Finally, if you just want to see if 2 16-bit values are both 0, then do
this:
ld hl,(var1)
ld de,(var2)
xor a
or h
or l
or d
or e
;Z flag if zero, NZ if not
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx