Search code examples
68000

68000 - How to I check if value in data register is odd using ANDI?


This is my code i have: I want to see whether the value in D1 is odd. If so i want to perform some operation. Can someone help me with this?

It would be nice if somone could show me an example of how to use it.


Solution

  • If you do a bit-wise AND of your input and a constant (immediate) value where only bit 0 is set, the result will be either 0 or 1, depending on the value of bit 1 in the input.

    So:

    check_odd:
        andi.b #1,d0
        beq.s  .even    ; If the result was zero, the Z flag is set, and beq jumps.
    .odd:
        ; We end up here if the value was odd.
        bra.s  .done
    .even:
        ; We end up here if the value was even.
    .done: