z80:Answers 4

From Learn @ Cemetech
Jump to navigationJump to search

1. Because using bitwise AND on a set bit doesn't change anything, this operation will preserve the byte as it is. However, it will modify the flags, though not usefully.

2. Note: these are not the only ways to set/reset the z flag, nor are they the best or even close to good.

   ;set z flag
   xor a
   
   ;reset z flag
   set 0,a
   or a

3. The very idea behind "XAND" is an oxymoron. The exclusive means that only one is true, but the AND means that both must be true, so there is no possible way for this instruction to exist.

4. Oops, this leaves all the bits unchanged instead of resetting. To reset all the bits, use AND 0.

5. Oops, should have used RES.

6. XOR A will always set the z flag, so you're stuck in an infinite loop.


   loop:
   ;...
   ;Operations that do something with z flag. We want to keep looping if z flag is set
   ;...
    xor a        ;set the accumulator to zero
    jr z,loop