Error[8]: Undefined offset: 22, File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 121
File: /www/wwwroot/outofmemory.cn/tmp/plugin_ss_superseo_model_superseo.php, Line: 473, decode(

基础汇编指令(16bit 32bit 64bit)

(zz from http://blog.luoyuanhang.com/)

##常见寄存器

寄存器 16位 32位 64位 累加寄存器

accumulator
AX EAX RAX 基址寄存器

base
BX EBX RBX 计数寄存器

count
CX ECX RCX 数据寄存器

data
DX EDX RDX 堆栈基指针

Base Pointer 
BP EBP RBP 变址寄存器

Source Index
SI ESI RSI 堆栈顶指针

Stack Pointer
SP ESP RSP 指令寄存器

Instruction Pointer
IP EIP RIP
AH&AL=AX(accumulator):累加寄存器
BH&BL=BX(base):基址寄存器
CH&CL=CX(count):计数寄存器
DH&DL=DX(data):数据寄存器
SP(Stack Pointer):堆栈指针寄存器
BP(Base Pointer):基址指针寄存器
SI(Source Index):源变址寄存器
DI(Destination Index):目的变址寄存器
IP(Instruction Pointer):指令指针寄存器
CS(Code Segment)代码段寄存器
DS(Data Segment):数据段寄存器
SS(Stack Segment):堆栈段寄存器
ES(Extra Segment):附加段寄存器 

##汇编指令

##mov

##push & pull

###堆栈数据结构简介

####作用:

####结构:

###push:压栈

###pop:出栈

##call&ret

###call

###ret

##enter&leave

###enter

push %ebp
movl %esp, %ebp
//将堆栈置空(栈上重堆)

###leave

movl %ebp, %esp
popl %ebp
//将堆栈置空(撤销堆栈)

##例子:分析一段汇编代码

pushl $8    ①
movl %ebp, %esp ②
subl $4, %esp ③
movl $8, (%esp) ④

   )
File: /www/wwwroot/outofmemory.cn/tmp/route_read.php, Line: 126, InsideLink()
File: /www/wwwroot/outofmemory.cn/tmp/index.inc.php, Line: 166, include(/www/wwwroot/outofmemory.cn/tmp/route_read.php)
File: /www/wwwroot/outofmemory.cn/index.php, Line: 30, include(/www/wwwroot/outofmemory.cn/tmp/index.inc.php)
基础汇编指令(16bit 32bit 64bit)_随笔_内存溢出

基础汇编指令(16bit 32bit 64bit)

基础汇编指令(16bit 32bit 64bit),第1张

基础汇编指令(16bit 32bit 64bit)

(zz from http://blog.luoyuanhang.com/)

##常见寄存器

寄存器 16位 32位 64位 累加寄存器

accumulator
AX EAX RAX 基址寄存器

base
BX EBX RBX 计数寄存器

count
CX ECX RCX 数据寄存器

data
DX EDX RDX 堆栈基指针

Base Pointer 
BP EBP RBP 变址寄存器

Source Index
SI ESI RSI 堆栈顶指针

Stack Pointer
SP ESP RSP 指令寄存器

Instruction Pointer
IP EIP RIP
AH&AL=AX(accumulator):累加寄存器
BH&BL=BX(base):基址寄存器
CH&CL=CX(count):计数寄存器
DH&DL=DX(data):数据寄存器
SP(Stack Pointer):堆栈指针寄存器
BP(Base Pointer):基址指针寄存器
SI(Source Index):源变址寄存器
DI(Destination Index):目的变址寄存器
IP(Instruction Pointer):指令指针寄存器
CS(Code Segment)代码段寄存器
DS(Data Segment):数据段寄存器
SS(Stack Segment):堆栈段寄存器
ES(Extra Segment):附加段寄存器 

##汇编指令

##mov

  • movb(8位)、movw(16位)、movl(32位)、movq(64位)

  • 寄存器寻址

    movl %eax, %edx

    eax -> edx

  • 立即数寻址:

    movl movl 0x123, %edxx123, %edx

    数字->寄存器

  • 直接寻址:

    movl (%ebx), %edx

    直接访问内存地址数据,edx = *(int32_t *)0x123;

  • 间接寻址:

    movl 4(%ebx), %edx

    %ebx 是个内存地址,(%ebx)指的是该地址中的数据,edx = *(int32_t*)ebx;

  • 变址寻址:

  • 程序调用框架
  • edx = *(int32_t*)(ebx+4);

##push & pull

###堆栈数据结构简介

####作用:

  • 传递参数
  • 保存返回地址
  • 提供局部变量
  • ……

####结构:

  • 相关寄存器: esp, ebp

  • 相关 *** 作: pop, push

    //建立被调用者函数的堆栈框架
    pushl %ebp
    movl %esp, %ebp //拆除框架
    movl %ebp, %esp
    popl %ebp
    ret

###push:压栈

  • push %eax

    相当于:

    subl $4, %esp
    //栈顶指针减4
    movl %eax, (%esp)
    //%eax -> esp 地址

###pop:出栈

  • pop %eax

    相当于:

    movl (%esp), %eax
    addl %4, %esp
    //栈顶指针加4

##call&ret

###call

  • call 0x12345

    相当于:

    pushl %eip
    movl $0x12345, %eip
    //当前地址压栈,存入新地址

###ret

  • 相当于:

    popl %eip
    //栈 -> eip

##enter&leave

###enter

push %ebp
movl %esp, %ebp
//将堆栈置空(栈上重堆)

###leave

movl %ebp, %esp
popl %ebp
//将堆栈置空(撤销堆栈)

##例子:分析一段汇编代码

pushl $8    ①
movl %ebp, %esp ②
subl $4, %esp ③
movl $8, (%esp) ④

   

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/587904.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存