0

I'm trying to reverse engineer a program and i found the following instruction:

test al, al
je label 

what does these two instruction do ? Can someone explain please ?

  • test equals and but does not place the result in the target operand. However, like and it manipulates the zero flag (ZF). – 0xC0000022L Jun 1 at 19:36
  • 1
    This is a standard idiom to test if the 8-bit value stored in AL (the register that is the low 8 bits of EAX) is zero. In other words, it's checking whether a Boolean is true or false, and branching accordingly. – Cody Gray Jun 2 at 3:17
4

In x86 assembly, al is the least significant byte of eax register, which is typically used to return values from function calls.

The test al,al is a bitwise AND operation between al and itself.

If al & al == 0, the zero flag will be set to 1.

je (or jz) instruction will jump to the address of label, if the zero flag is 1. Otherwise, the je will do nothing.

In short: If eax == ######00 jump to label.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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