汇编语言导论Introduction To Assembly

本文介绍了汇编语言的基本概念,包括其与高级语言的区别、关键知识点如指令、寄存器、寻址和函数调用。讲解了如何通过汇编进行内存操作,以及在不同操作系统下的实践,并探讨了RISC和CISC处理器的寻址模式差异。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

语言

高级语言:

  • 非常具有人类可读性
  • 一行可以做很多事
  • 可快速编写以及调试
  • 非常适合企业软件

汇编语言:

  • 对CPU的要求很少
  • 大量控制
  • 执行速度非常快
  • 只需要很少的运行时支持
  • 非常适合嵌入式(embedded)/微型(tiny)系统

关于汇编的关键知识:

  • 指令易于编写和理解
  • 你需要很多个指令
  • 一些东西你必须自己动手去编写
    • 循环,基于块的流控制
  • 变量与高级语言的有所不同

变量

在高级语言中,当你看到 int a;

这意味着:分配空间给a,并允许我用a去引用这个空间。

这个空间可能是栈或者堆。

这是汇编语言通常无法提供的高级抽象。

关于我们如何存储字符串,数组,链表:

我们在寄存器中存储一个指向一个地址的指针,并使用它作为引用内存的基础。

寄存器(Registers)

每个CPU有一个小数量的(通常是8-16个)硬件“变量”。在机器内部,这些都有编号。在汇编中,我们将经常看到它们以相同的方式编号:例如R0 - R15。

在x86/x64中,你将会看到一些带有名字(rax,rbx,rcx)和数字(r8-r15)的寄存器。

你可以在你的

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.
A Revised and Updated Edition of the Authoritative Text This revised and updated Third Edition of the classic text guides students through assembly language using a hands-on approach, supporting future computing professionals with the basics they need to understand the mechanics and function of the computer’s inner workings. Through using real instruction sets to write real assembly language programs, students will become acquainted with the basics of computer architecture. 80×86 Assembly Language and Computer Architecture covers the Intel 80×86 using the powerful tools provided by Microsoft Visual Studio, including its 32- and 64-bit assemblers, its versatile debugger, and its ability to link assembly language and C/C++ program segments. The text also includes multiple examples of how individual 80×86 instructions execute, as well as complete programs using these instructions. Hands-on exercises reinforce key concepts and problem-solving skills. Updated to be compatible with Visual Studio 2012, and incorporating over a hundred new exercises, 80×86 Assembly Language and Computer Architecture: Third Edition is accessible and clear enough for beginning students while providing coverage of a rich set of 80×86 instructions and their use in simple assembly language programs. The text will prepare students to program effectively at any level. Key features of the fully revised and updated Third Edition include: Updated to be used with Visual Studio 2012, while remaining compatible with earlier versions Over 100 new exercises and programming exercises Improved, clearer layout with easy-to-read illustrations The same clear and accessibly writing style as previous editions Full suite of ancillary materials, including PowerPoint lecture outlines, Test Bank, and answer keys Suitable as a stand-alone text in an assembly language course or as a supplement in a computer architecture course
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值