[Assembly] 程序的机器级表示(一)

数据格式

C声明Intel数据类型汇编代码后缀大小(字节)
char字节b1
shortw2
int双字l4
long四字q8
char *四字q8
float单精度s4
double双精度l8

寄存器

主要用途64位寄存器名32位寄存器名16位寄存器名8位寄存器名
存储返回值%rax%eax%ax%al
被调用者保存%rbx%ebx%bx%bl
第四个参数%rcx%ecx%cx%cl
第三个参数%rdx%edx%dx%dl
第二个参数%rsi%esi%si%sil
第一个参数%rdi%edi%di%dil
被调用者保存%rbp%ebp%bp%bpl
栈指针%rsp%esp%sp%spl
第五个参数%r8%r8d%r8w%r8b
第六个参数%r9%r9d%r9w%r9b
调用者保存%r10%r10d%r10w%r10b
调用者保存%r11%r11d%r11w%r11b
被调用者保存%r12%r12d%r12w%r12b
被调用者保存%r13%r13d%r13w%r13b
被调用者保存%r14%r14d%r14w%r14b
被调用者保存%r15%r15d%r15w%r15b

操作数指示符

  • 立即数:$ + C语言表示法的整数
    如: $ 0x2A $3000
  • 寄存器: % + 寄存器名
    如: %eax %rbp
  • 内存引用: Imm(Rb, Ri, s)
    其中Imm代表立即数,Rb是一个存储在寄存器中的偏移量,Ri也是存储在寄存器中的偏移量,S是Ri的偏移倍数(s必须是1、2、4、8),计算方法是:Imm + (Rb) + (Ri) * s。
    如:260(%rcx, %rdx) (%rbx)

    对于寄存器,%rax代表%rax寄存器存储的值,而(%rax)代表%rax寄存器指向的内存单元的值。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
This book introduces programmers to 64 bit Intel assembly language using the Microsoft Windows operating system. The book also discusses how to use the free integrated development environment, ebe, designed by the author specifically to meet the needs of assembly language programmers. Ebe is a C++ program which uses the Qt library to implement a GUI environment consisting of a source window, a data window, a register window, a floating point register window, a backtrace window, a console window, a terminal window, a project window and a pair of teaching tools called the "Toy Box" and the "Bit Bucket". The source window includes a full-featured text editor with convenient controls for assembling, linking and debugging a program. The project facility allows a program to be built from C source code files and assembly source files. Assembly is performed automatically using the yasm assembler and linking is performed with ld or gcc. Debugging operates by transparently sending commands into the gdb debugger while automatically displaying registers and variables after each debugging step. The Toy Box allows the use to enter variable definitions and expressions in either C++ or Fortran and it builds a program to evaluate the expressions. Then the user can inspect the format of each expression. The Bit Bucket allows the user to explore how the computer stores and manipulates integers and floating point numbers. Additional information about ebe can be found at http://www.rayseyfarth.com. The book is intended as a first assembly language book for programmers experienced in high level programming in a language like C or C++. The assembly programming is performed using the yasm assembler automatically from the ebe IDE under the Linux operating system. The book primarily teaches how to write assembly code compatible with C programs. The reader will learn to call C functions from assembly language and to call assembly functions from C in addition to writing complete programs in assembly language. The gcc compiler is used internally to compile C programs. The book starts early emphasizing using ebe to debug programs. Being able to single-step assembly programs is critical in learning assembly programming. Ebe makes this far easier than using gdb directly. Highlights of the book include doing input/output programming using Windows API functions and the C library, implementing data structures in assembly language and high performance assembly language programming. Early chapters of the book rely on using the debugger to observe program behavior. After a chapter on functions, the user is prepared to use printf and scanf from the C library to perform I/O. The chapter on data structures covers singly linked lists, doubly linked circular lists, hash tables and binary trees. Test programs are presented for all these data structures. There is a chapter on optimization techniques and 3 chapters on specific optimizations. One chapter covers how to efficiently count the 1 bits in an array with the most efficient version using the recently-introduced popcnt instruction. Another chapter covers using SSE instructions to create an efficient implementation of the Sobel filtering algorithm. The final high performance programming chapter discusses computing correlation between data in 2 arrays. There is an AVX implementation which achieves 20.5 GFLOPs on a single core of a Core i7 CPU. A companion web site, http://www.rayseyfarth.com, has a collection of PDF slides which instructors can use for in-class presentations and source code for sample programs.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值