Assembly language operand types

x86 instruction format is:

 

[label:] mnemonic [operands][ ;comment ]

Number of operands included in the instruction can be: 0, 1, 2 or 3. Here, for clarity, reference numerals and omitted Notes:

mnemonic
mnemonic [destination] mnemonic [destination] , [source] mnemonic [destination] , [source-1] , [source-2]

Operands are three basic types:

  • Immediate - digital text expression
  • Register operand - using the CPU registers named
  • Memory operand - referenced memory location

The following table illustrates the types of operands standard, which uses a simple operand symbol (32-bit mode), the symbols from Intel and a manual adaptation. This tutorial syntax of these symbols to describe each instruction.

Number of operations Explanation
reg8 8 general-purpose registers: AH, AL, BH, BL, CH, CL, DH, DL
Regl6 16-bit general purpose registers: AX, BX, CX, DX, SI, DI, SP, BP
reg32 32-bit general purpose registers: EAX, EEX, ECX, EDX, ESI, EDI, ESP, EBP
reg General-purpose registers
comfortable 16-bit segment register: CS, DS, SS, ES, FS, GS
imm 8, 16-bit or 32-bit immediate data
imm8 8, immediate byte value
imm16 16, immediate word values
imm32 32-bit immediate data, double word value
reg/mem8 8 operand may be an 8-bit general purpose registers or memory byte
reg/mem16 16-bit immediate data may be a 16 bit general purpose register or a memory word
reg/mem32 32-bit immediate which can be 32-bit double word general register or memory
mem 8, 16-bit or 32-bit memory operand

Direct memory operand

Reference to the variable name is the offset within the data segment. For example, the following declaration of variables varl indicates the size of the variable type byte hexadecimal value 10:

  .data  var1 BYTE 10h

You can write command, the address of the memory operand to resolve (find) these operands. Suppose var1 offset address 10400h. The following command to copy the value of the variable register AL:

  mov al var1

Instruction is compiled into the following machine instructions:

  A0 00.0104 million

This first byte is the operation code of the machine instruction (i.e. an operation code (opcode)). Var1 remainder being 32-bit hexadecimal address. While programming is possible using only numeric addresses, but the same sign as var1 labels will make it easier to use memory.

Another notation. Some programmers prefer to use such a direct expression operand below, because, braces means parsing operation:

  mov al, [var1]

MASM allow this representation, so as long as you are willing to be used in the program. Since most programs (including Microsoft program) are not printed in parentheses, so the book only in the event of representation when using this arithmetic expressions with parentheses:

  mov al, [var1 + 5]

Next: MOV instruction

Highly recommended reading articles

40 + annual salary of big data development [W] tutorial, all here!

Guess you like

Origin blog.csdn.net/Javaxuxuexi/article/details/93312972