Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Question about the Intel's IA-32 software developer manual

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.

like image 961
Francesco Turco Avatar asked Jan 23 '23 05:01

Francesco Turco


2 Answers

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)

like image 97
Virgil Avatar answered Jan 29 '23 09:01

Virgil


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.

like image 35
GJ. Avatar answered Jan 29 '23 10:01

GJ.