• x86汇编


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

  • 相关阅读:
    socket.io+angular.js+express.js做个聊天应用(二)
    [原创]Python通过Thrift连接HBase
    [原创]安装Sqoop并验证
    使用PostgreSQL、Hibernate 构建 NoSQL
    [原创]HBase客户端开发举例(第三部分)
    [原创]HBase客户端开发举例(第二部…
    [原创]全分布模式下Hadoop安装
    Samba的基本配置
    常见设计模式举例 转载有改动
    【转载】hibernate中使用ehcache
  • 原文地址:https://www.cnblogs.com/passion-hzhang/p/6275694.html
Copyright © 2020-2023  润新知