fizixx
fizixx

Reputation: 163

Correct encoding for x86 ADD instruction

I manually encode the following instruction:

add [di], al

And according to my understanding of the x86 documentation, the corresponding machine code should be:

00 07

When compiling the above code with nasm, I get the following:

# echo "add [di], al" > test.asm && nasm test.asm && xxd -ps test
0005

The same happens when compiling with as.

I suspect this has something to do with 16/32/64 bit encoding, but I cannot find information around this.

Upvotes: 1

Views: 124

Answers (1)

coladict
coladict

Reputation: 5095

No, according to this reference 00 07 corresponds to add [bx], al and 00 05 is correct for add [di], al.

Upvotes: 3

Related Questions