Logical Instruction

The logical instructions perform basic AND, OR, XOR, and NOT logical operations on byte, word, and doubleword values. We should know the truth table for these operations.

AND operation- A&B, OR operation- A|B, XOR operation- a^b, NOT operation- ~a

Lets understand it better via code (logical.nasm)

Defining hook-stop to keep and eye on each register’s value.

Below, we can see the operations, and can validate the result (checked in python). Here we had one register and one immediate value. OPERATION REG, VALUE ; in this final value is stored in register itself.

OPERATION MEMORY, VALUE ; in this final value is stored in memory address itself.

Similarly we can look remaining instructions.

Everything here is simple as long as we know the truth table of operations.

💡 Most of the time, XOR operation can be seen as used as clearing the register, i.e. 0x0. Instead of directly moving value 0x0 in the register.

Last updated