1

During my current project I found such code:

move.w  (0xFFFC0C).l, d0 | read SCSR
andi.w  #0x100, d0       | add 256 to d0
beq.s   location         | branch if LSB = 0x00

I cannot get the idea of this fragment. I guess author tried to check the status of the UART, but how does andi.w and beq.s serves the purpose, when SCSR may contain maximum of 9 bits?

enter image description here

1
  • It's not adding. It is binary AND operation, exactly as single & in C language.
    – w s
    Jul 11, 2017 at 10:30

1 Answer 1

4

It's not adding. It is binary and operation, and in translation to C the code looks as follows:

d0 = readSCSR(); // move.w  (0xFFFC0C).l, d0 | read SCSR
if (d0 & 0x100) 
//andi.w  #0x100, d0       | not add, but AND 256 to d0
//beq.s   location         | branch if LSB = 0x00
{
    // do whatever needed
}
location: // else branch to location

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.