码迷,mamicode.com
首页 > 其他好文 > 详细

x86汇编

时间:2017-01-12 12:53:48      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:立即数   gis   odi   $0   mode   memory   data   cpu   point   

memory holds instructions and data

CPU interpreter of instructions

 

EIP is incremented after each instruction

instruction are different length

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

 

Registers for work space

eax 累加器(Accumulator)

ebs 基地址寄存器 Base Registers

ecx 计数寄存器 count Registers

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寄存器不能被直接修改,只能通过特殊指令间接修改。

 

x86汇编

标签:立即数   gis   odi   $0   mode   memory   data   cpu   point   

原文地址:http://www.cnblogs.com/passion-hzhang/p/6275694.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!