Search code examples
assemblyx86bitwise-and

What does tests $1,%al do in assembly?


So there is a value in %eax = x.

I have the lines:

tests $1,%al
je .L2

So I know it is doing 1&%al and then jumps if equal. My question is what is%al given %eax is x (I know %al is the least significant byte. I want to know what it is in term of x). And what does it mean for it to be equal to 1??


Solution

  • In terms of x, %al is really only the least significant byte. What you're doing is looking at just "part of x", or the part that contributes values of up to 255 to the total value of x. Might sound vague.

    One thing this could mean is that x is odd because it has a least significant 1, in which case you don't have to look at x as a whole. I couldn't safely draw any other strong conclusions.