views:

94

answers:

2

I'm studying the Intel's IA-32 software developer manual. In particular, I'm reading the following manual: http://www.intel.com/Assets/PDF/manual/253666.pdf. Let's take for example the ADD instruction. On page 79 it is written that you can add an r8 (8-bit register) to an r/m8 (8-bit register or memory location). A few rows below, it is also written that you can add an r/m8 to an r8. The question is: if I add two 8-bit registers, which instruction I am using? Thanks.

+7  A: 

The add instruction has multiple versions... same mnemonic can be encoded to different opcodes, depending on what operands you use. (and to answer your specific question: the "add r8,r8" instruction probably has 2 different possible encodings, that do the same thing)

Virgil
Similar to overloaded functions?
dboarman
for some definitions of "similar"...... i guess you could say so :)
Virgil
+1  A: 

The ADD instruction has 9 different encoding types and two opcodes are reserved for:

Opcode: 00/r = ADD r/m8, r8
Opcode: 02/r = ADD r8, r/m8

In case "ADD r8, r8" both have some effect.

GJ