Domanda

Quali sono esattamente le istruzioni

movzbl  0x01(%eax,%ecx),%eax

fa?

È stato utile?

Soluzione

sintassi AT & T divide le movzx istruzioni Intel mnemoniche in diverse mnemonici per dimensioni diverse sorgenti ( movzb vs movzw). Nella sintassi Intel, è:

movzx eax, byte ptr [eax+ecx+1]

vale a dire. caricare un byte dalla memoria eax + ecx + 1 e zero estendono a pieno registro.

A proposito, la maggior parte degli strumenti GNU ora dispone di un interruttore o di un opzione di configurazione a preferire la sintassi Intel. (Come objdump -Mintel o gcc -S -masm=intel, anche se quest'ultimo influenza la sintassi utilizzata quando si compila linea-asm). Raccomando certamente ad esaminare il problema, se non fai AT & T di assemblaggio per la vita. Si veda anche la wiki tag per ulteriori documenti e guide .

Altri suggerimenti

Minimal example

mov $0x01234567, %eax
mov $1, %bl
movzbl %bl, %eax
/* %eax == 0000 0001 */

mov $0x01234567, %eax
mov $-1, %bl
movzbl %bl, %eax
/* %eax == 0000 00FF */

Runanble GitHub upstream with assertions.

The mnemonic is:

  • MOV
  • Zero extend
  • Byte (8-bit)
  • to Long (32-bit)

There are also versions for other sizes:

  • movzbw: Byte (8-bit) to Word (16-bit)
  • movzwl: Word (16-bit) to Long (32-bit)

Like most GAS instructions, you can omit the last size character when dealing with registers:

movzb %bl, %eax

but I cannot understand why we can't omit the before last letter, e.g. the following fails:

movz %bl, %eax

Why not just deduce it from the size of the operands when they are registers as for mov and Intel syntax?

And if you use registers of the wrong size, it fails to compile e.g.:

movzb %ax, %eax
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top