Re: A83: Setting a bit...


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

Re: A83: Setting a bit...




On 18 Jan 00, at 13:46, James Matthews wrote:


Hey there,

Ok, question here...what's a good way to toggle the nth bit of a byte when n is stored in
a register? For example:

 ld a,3

;
; Necessary code here
;

And the 3rd bit is set/reset. I thought of creating a bitmask on-the-fly then XORing it,
or perhaps making a lookup table...but I'm still not too sure. Help? :)

Later,

James.


- James Matthews
Generation5: http://www.generation5.org/


use the xor command.  xor a,3

sets/resets the first and second bits- the code to set third is xor 
a,4.

Assuming you count from zero to seven, of course.


They say one has to be good in this business.  Well I'm better.

-The Godfather


Follow-Ups: References: