Re: LZ: Bit comparison
[Prev][Next][Index][Thread]
Michael wrote:
>
> is there an easy way to do a bit comparison operation. i don't think
> the BIT operation is exactly what i am looking for. to my
> understanding, BIT 3,A will be equivalent to A & 00000100.
> what i want to do is have a value in register A, such as 10001011 and
> then look at the 4th bit and test to see if it is a 0 or 1. in other
> words, my input will possibly have more than one 1 in it. can anyone
> help?
>
> -mike
Nope, you do want BIT. It tests the selected bit in A and sets the
appropiate flags.
For example...
ld a,%10001011 ;puts in the value you want to test
BIT 4,a ;tests fourth bit, but actually the bitnumbers
;are as follows: "765'4'3210", so 2^4 is bit
;four
JUMP_Z(itwaszero) ;this jumps because the last command resulted in
;a zero, thus the _Z
JUMP_NZ(itwasone) ;this jumps if the last command resulted in a
;nonzero, hence the _NZ
In that case, the selected bit was zero, so it would have gone to
itwaszero. Also, I think you can do this to other registers, but I'm not
sure.
<pre>
--
Compliments of:
_-_-_-_-_-_-_-_
Alan Bailey
mailto:bailala@mw.sisna.com
IRC:Abalone
Web:http://www.mw.sisna.com/users/bailala/home.htm
</pre>
References: