MCF
MCF

Reputation: 57

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??

Upvotes: 0

Views: 1409

Answers (3)

Ruben
Ruben

Reputation: 540

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.

Upvotes: 2

nvuono
nvuono

Reputation: 3363

EAX register (the accumulator register) can be logically divided into:

  • AX 2 least significant bytes (16 bits),
  • AH high byte of AX
  • AL low byte of AX (least significant byte overall)

What it means depends on what is using your accumulator register.

It is typically used for IO access, arithmetic and interrupts.

If this is generated from some C code could it be assuming that the type of X is a byte and you don't need to send a larger word down the pipeline for the comparison?

Upvotes: 1

grillo
grillo

Reputation: 356

AL is the least significant byte of EAX.

Upvotes: 0

Related Questions