x86彙編

memory holds instructions and dataspa

CPU interpreter of instructions指針

 

EIP is incremented after each instructionip

instruction are different length內存

EIP modified by CALL, RET, JMP, and conditional JMPrem

 

Registers for work spaceit

eax 累加器(Accumulator)io

ebs 基地址寄存器 Base Registersim

ecx 計數寄存器 count Registerscall

edx 數據寄存器 data registers數據

ebp 堆棧基指針 base pointer

esi  edi 變址寄存器 index register

esp 堆棧頂指針 stack pointer

 

movl %eax, %edx         edx=eax;     register mode

movl $0x123, %edx       edx=0x123;  immediate

注:當即數是以$開頭的數值

movl 0x123, %edx        edx=*(int32_t*)0x123; direct

注:直接尋址:直接訪問一個指定的內存地址的數據;

movl (%ebx), %edx      edx=*(int32_t*)ebx; indirect

注:間接尋址:將寄存器的的值做爲一個內存地址來訪問內存。

movl 4(%ebx), %edx    edx=*(int32_t*)(ebx+4); displace

注:變址尋址:在間接尋址之時改變寄存器的數值

 

stack memory + operations

push %eax    等價於  subl $4, %esp    movl %eax, (%esp)

esp向下移一個位; eax的值存放到esp所指向的地址空間

pop %eax      等價於 movl (%esp), %eax  add $4, %esp

將esp所指向地址的數值傳遞給eax,同時esp向上移一位

call 0x12345   等價於 pushl %eip(*)   movl $0x12345, %eip(*)

將eip入棧,同時 將當即數賦給eip。

ret   等價於 popl %eip(*)  將以前的eip的數值還給eip。

eip寄存器不能被直接修改,只能經過特殊指令間接修改。

相關文章
相關標籤/搜索