Move 指令寻址方式

来源:互联网 发布:淘宝店掌柜名怎么改 编辑:程序博客网 时间:2024/05/22 17:32

1:Moving immediate data to registers and memory

movl $0, %eax                  # moves the value 0 to the EAX register
movl $0x80, %ebx            # moves the hexadecimal value 80 to the EBX register
movl $100, height             # moves the value 100 to the height memory location

2:Moving data between registers

The eight general-purpose registers (EAX, EBX, ECX, EDX, EDI, ESI, EBP, and ESP) are the most common
registers used for holding data.
(1): These registers can be moved to any other type of register available.
(2):the special-purpose registers (the control, debug, and segment registers) can only be moved to or from a general-purpose register.
 (3):Moving data between similarly sized registers

3:Moving data between memory and registers

 (1):Moving data values from memory to a register

       movl value, %eax

 (2):Moving data values from a register to memory

      movl %ecx, value

 (3):Using indexed memory locations

values:.int 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60
When referencing data in the array, you must use an index system to determine which value you are accessing.
 The way this is done is called indexed memory mode. The memory location is determined by the
following:
❑ A base address
❑ An offset address to add to the base address
❑ The size of the data element
❑ An index to determine which data element to select
The format of the expression is   base_address(offset_address, index, size)
The data value retrieved is located at
base_address + offset_address + index * size
If any of the values are zero, they can be omitted (but the commas are still required as placeholders).
movl values(, %edi, 4), %eax

 (4):Using indirect addressing with registers

When a register holds a memory address, it is referred to as a pointer.
Accessing the data stored in the memory location using the pointer is called indirect addressing.,
movl $output, %edimovl %edx, 4(%edi)movl %ebx, (%edi)
A:   it enables you to control memory address locations with a register. 
B:   The real power is realized by incrementing the indirect addressing value contained in the register.