详细的揭示了linux下的AT&T汇编指令使用方法,给出了各种汇编指令,指令用法,以及相应的例程。其中包括一些如何使用汇编链接C语言库,汇编调用系统调用,汇编执行浮点运算,C语言内嵌汇编等。 Chapter 1: What Is Assembly Language? 1 Processor Instructions 1 Instruction code handling 2 Instruction code format 3 High-Level Languages 6 Types of high-level languages 7 High-level language features 9 Assembly Language 10 Opcode mnemonics 11 Defining data 12 Directives 14 Summary 15 Chapter 2: The IA-32 Platform 17 Core Parts of an IA-32 Processor 17 Control unit 19 Execution unit 24 Registers 25 Flags 29 Advanced IA-32 Features 32 The x87 floating-point unit 32 Multimedia extensions (MMX) 33 Streaming SIMD extensions (SSE) 33 Hyperthreading 34 The IA-32 Processor Family 34 Intel processors 35 Non-Intel processors 36 Summary 37 Chapter 3: The Tools of the Trade 39 The Development Tools 39 The Assembler 40 The Linker 42 The Debugger 43 The Compiler 44 The object code disassembler 44 The Profiler 44 The GNU Assembler 45 Installing the assembler 45 Using the assembler 47 A word about opcode syntax 49 The GNU Linker 50 The GNU Compiler 53 Downloading and installing gcc 53 Using gcc 54 The GNU Debugger Program 56 Downloading and installing gdb 56 Using gdb 57 The KDE Debugger 60 Downloading and installing kdbg 60 Using kdbg 60 The GNU Objdump Program 62 Using objdump 63 An objdump example 64 The GNU Profiler Program 65 Using the profiler 65 A profile example 68 A Complete Assembly Development System 69 The basics of Linux 69 Downloading and running MEPIS 70 Your new development system 71 Summary 72 Chapter 4: A Sample Assembly Language Program 73 The Parts of a Program 73 Defining sections 74 Defining the starting point 74 Creating a Simple Program 75 The CPUID instruction 76 The sample program 77 Building the executable 80 Running the executable 80 Assembling using a compiler 80 Debugging the Program 81 Using gdb 81 Using C Library Functions in Assembly 86 Using printf 87 Linking with C library functions 88 Summary 90 Chapter 5: Moving Data 91 Defining Data Elements 91 The data section 91 Defining static symbols 94 The bss section 95 Moving Data Elements 97 The MOV instruction formats 97 Moving immediate data to registers and memory 98 Moving data between registers 99 Moving data between memory and registers 99 Conditional Move Instructions 106 The CMOV instructions 107 Using CMOV instructions 109 Exchanging Data 110 The data exchange instructions 111 Using the data exchange instruction 116 The Stack 119 How the stack works 119 PUSHing and POPing data 120 PUSHing and POPing all the registers 123 Manually using the ESP and EBP registers 123 Optimizing Memory Access 123 Summary 124 Chapter 6: Controlling Execution Flow 127 The Instruction Pointer 127 Unconditional Branches 129 Jumps 129 Calls 132 Interrupts 135 Conditional Branches 136 Conditional jump instructions 136 The compare instruction 138 Examples of using the flag bits 140 Loops 144 The loop instructions 144 A loop example 145 Preventing LOOP catastrophes 145 Duplicating High-Level Conditional Branches 146 if statements 147 for loops 150 Optimizing Branch Instructions 153 Branch prediction 153 Optimizing tips 155 Summary 158 Chapter 7: Using Numbers 161 Numeric Data Types 161 Integers 162 Standard integer sizes 162 Unsigned integers 164 Signed integers 166 Using signed integers 168 Extending integers 169 Defining integers in GAS 172 SIMD Integers 173 MMX integers 173 Moving MMX integers 174 SSE integers 176 Moving SSE integers 177 Binary Coded Decimal 178 What is BCD? 178 FPU BCD values 179 Moving BCD values 180 Floating-Point Numbers 182 What are floating-point numbers? 182 Standard floating-point data types 184 IA-32 floating-point values 186 Defining floating-point values in GAS 187 Moving floating-point values 187 Using preset floating-point values 189 SSE floating-point data types 190 Moving SSE floating-point values 191 Conversions 196 Conversion instructions 196 A conversion example 198 Summary 199 Chapter 8: Basic Math Functions 201 Integer Arithmetic 201 Addition 201 Subtraction 210 Incrementing and decrementing 215 Multiplication 216 Division 221 Shift Instructions 223 Multiply by shifting 224 Dividing by shifting 225 Rotating bits 226 Decimal Arithmetic 227 Unpacked BCD arithmetic 227 Packed BCD arithmetic 229 Logical Operations 231 Boolean logic 231 Bit testing 232 Summary 233 Chapter 9: Advanced Math Functions 235 The FPU Environment 235 The FPU register stack 236 The FPU status, control, and tag registers 237 Using the FPU stack 242 Basic Floating-Point Math 245 Advanced Floating-Point Math 249 Floating-point functions 249 Partial remainders 252 Trigonometric functions 254 Logarithmic functions 257 Floating-Point Conditional Branches 259 The FCOM instruction family 260 The FCOMI instruction family 262 The FCMOV instruction family 263 Saving and Restoring the FPU State 265 Saving and restoring the FPU environment 265 Saving and restoring the FPU state 266 Waiting versus Nonwaiting Instructions 269 Optimizing Floating-Point Calculations 270 Summary 270 Chapter 10: Working with Strings 273 Moving Strings 273 The MOVS instruction 274 The REP prefix 278 Other REP instructions 283 Storing and Loading Strings 283 The LODS instruction 283 The STOS instruction 284 Building your own string functions 285 Comparing Strings 286 The CMPS instruction 286 Using REP with CMPS 288 String inequality 289 Scanning Strings 291 The SCAS instruction 292 Scanning for multiple characters 293 Finding a string length 295 Summary 296 Chapter 11: Using Functions 297 Defining Functions 297 Assembly Functions 299 Writing functions 299 Accessing functions 302 Function placement 304 Using registers 304 Using global data 304 Passing Data Values in C Style 306 Revisiting the stack 306 Passing function parameters on the stack 306 Function prologue and epilogue 308 Defining local function data 309 Cleaning out the stack 312 An example 312 Watching the stack in action 314 Using Separate Function Files 317 Creating a separate function file 317 Creating the executable file 318 Debugging separate function files 319 Using Command-Line Parameters 320 The anatomy of a program 320 Analyzing the stack 321 Viewing command-line parameters 323 Viewing environment variables 325 An example using command-line parameters 326 Summary 328 Chapter 12: Using Linux System Calls 329 The Linux Kernel 329 Parts of the kernel 330 Linux kernel version 336 System Calls 337 Finding system calls 337 Finding system call definitions 338 Common system calls 339 Using System Calls 341 The system call format 341 Advanced System Call Return Values 346 The sysinfo system call 346 Using the return structure 347 Viewing the results 348 Tracing System Calls 349 The strace program 349 Advanced strace parameters 350 Watching program system calls 351 Attaching to a running program 353 System Calls versus C Libraries 355 The C libraries 356 Tracing C functions 357 Comparing system calls and C libraries 358 Summary 359 Chapter 13: Using Inline Assembly 361 What Is Inline Assembly? 361 Basic Inline Assembly Code 365 The asm format 365 Using global C variables 367 Using the volatile modifier 369 Using an alternate keyword 369 Extended ASM 370 Extended ASM format 370 Specifying input and output values 370 Using registers 372 Using placeholders 373 Referencing placeholders 376 Alternative placeholders 377 Changed registers list 377 Using memory locations 379 Using floating-point values 380 Handling jumps 382 Using Inline Assembly Code 384 What are macros? 384 C macro functions 384 Creating inline assembly macro functions 386 Summary 387 Chapter 14: Calling Assembly Libraries 389 Creating Assembly Functions 389 Compiling the C and Assembly Programs 391 Compiling assembly source code files 392 Using assembly object code files 392 The executable file 393 Using Assembly Functions in C Programs 395 Using integer return values 396 Using string return values 397 Using floating-point return values 400 Using multiple input values 401 Using mixed data type input values 403 Using Assembly Functions in C++ Programs 407 Creating Static Libraries 408 What is a static library? 408 The ar command 409 Creating a static library file 410 Compiling with static libraries 412 Using Shared Libraries 412 What are shared libraries? 412 Creating a shared library 414 Compiling with a shared library 414 Running programs that use shared libraries 415 Debugging Assembly Functions 417 Debugging C programs 417 Debugging assembly functions 418 Summary 420 Chapter 15: Optimizing Routines 421 Optimized Compiler Code 421 Compiler optimization level 1 422 Compiler optimization level 2 423 Compiler optimization level 3 425 Creating Optimized Code 425 Generating the assembly language code 425 Viewing optimized code 429 Recompiling the optimized code 429 Optimization Tricks 430 Optimizing calculations 430 Optimizing variables 433 Optimizing loops 437 Optimizing conditional branches 442 Common subexpression elimination 447 Summary 450 Chapter 16: Using Files 453 The File-Handling Sequence 453 Opening and Closing Files 454 Access types 455 UNIX permissions 456 Open file code 458 Open error return codes 459 Closing files 460 Writing to Files 460 A simple write example 460 Changing file access modes 462 Handling file errors 462 Reading Files 463 A simple read example 464 A more complicated read example 465 Reading, Processing, and Writing Data 467 Memory-Mapped Files 470 What are memory-mapped files? 470 The mmap system call 471 mmap assembly language format 473 An mmap example 475 Summary 479 Chapter 17: Using Advanced IA-32 Features 481 A Brief Review of SIMD 481 MMX 482 SSE 483 SSE2 483 Detecting Supported SIMD Operations 483 Detecting support 484 SIMD feature program 485 Using MMX Instructions 487 Loading and retrieving packed integer values 487 Performing MMX operations 488 Using SSE Instructions 497 Moving data 498 Processing data 499 Using SSE2 Instructions 504 Moving data 505 Processing data 505 SSE3 Instructions 508 Summary 508 Index 511 AT&T汇编语言是一门低级编程语言,它允许程序员与计算机硬件进行更直接的交互。本资料详细介绍了在Linux系统下使用AT&T汇编语言的方法,包括各种指令、指令用法以及相关的例程。以下是一些关键知识点的详细说明: 1. 汇编语言基础:汇编语言是一种依赖于处理器架构的语言,它将机器代码指令映射为人类可读的助记符。助记符代表指令,而操作数则是指令作用的数据。在AT&T语法中,操作数的顺序通常与Intel语法相反,且指令前会加上一个“%”符号。 2. IA-32平台:IA-32是英特尔的一个32位处理器架构,它包含许多核心部件,如控制单元和执行单元,以及寄存器和标志位。它还拥有高级特性,如x87浮点单元、MMX、SSE和超线程技术。 3. 开发工具:文档描述了在Linux下开发AT&T汇编程序所需的各种工具,例如汇编器、链接器、调试器、编译器以及反汇编器。特别强调了GNU工具链,包括GNU汇编器(GAS)、GNU链接器(LD)、GNU编译器(GCC)和GNU调试器(GDB)。 4. 示例程序:通过创建简单的汇编语言程序,文档展示了如何编写代码,如何将其编译为可执行文件,以及如何使用gdb进行调试。它还探讨了在汇编程序中使用C语言库函数和printf函数。 5. 数据传输:在汇编语言中,如何移动数据是基础操作之一。文档详细讲解了数据的定义、数据段、MOV指令的格式以及如何在寄存器、内存之间移动数据。 6. 控制执行流程:介绍了如何使用跳转(jumps)、调用(calls)、中断(interrupts)、循环(loops)和条件分支来控制程序的执行流程。还讨论了循环优化和分支预测的技术。 7. 使用数字:包括整数、SIMD整数、MMX和SSE整数以及浮点数。介绍了不同数据类型在GAS中的定义、使用BCD和FPU进行的浮点运算和转换。 8. 基本数学功能:介绍了整数和浮点数的算术运算,包括加法、减法、乘法、除法以及逻辑操作。还包括了位移和旋转指令。 9. 高级数学功能:涉及FPU环境、浮点栈操作,以及使用FPU进行基本和高级浮点数学运算,包括三角函数和对数函数。 10. 字符串操作:包括移动字符串、比较字符串、扫描字符串和计算字符串长度。 11. 函数的使用:展示了如何在汇编语言中定义和调用函数,包括参数传递和局部数据的定义。 12. Linux系统调用:解释了如何在汇编语言中使用Linux系统调用来进行I/O操作、进程控制和内存管理。 13. 内联汇编:介绍了在C或C++程序中如何使用内联汇编代码来执行特定的CPU指令。 14. 调用汇编库:讲解了如何创建和使用汇编语言编写的库函数,并在C或C++程序中调用这些函数。 15. 优化例程:讨论了编译器优化级别的设置以及创建、查看和重新编译优化代码的技术。 16. 文件处理:涵盖了文件的打开、关闭、读写以及内存映射文件的使用。 17. 高级IA-32特性:介绍了如何利用IA-32平台的高级特性,如SIMD技术,包括MMX、SSE、SSE2和SSE3指令集进行数据处理。 本资料旨在为开发者提供一个全面的指南,帮助他们在Linux环境下使用AT&T汇编语言进行高效的程序开发。通过对汇编指令的深入理解和实际应用,程序员能够编写出更加高效和优化的代码。同时,还介绍了如何与C语言进行互操作,以及如何调用操作系统提供的系统调用。通过内联汇编和调用汇编库的高级技术,可以进一步提升程序性能。优化技术和使用高级IA-32特性可以让程序利用现代CPU的强大功能。
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/octet-stream](https://img-home.csdnimg.cn/images/20210720083646.png)
![application/pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![application/pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![application/x-gzip](https://img-home.csdnimg.cn/images/20250102104920.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![application/x-gzip](https://img-home.csdnimg.cn/images/20250102104920.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![doc](https://img-home.csdnimg.cn/images/20241231044833.png)
![](https://csdnimg.cn/release/download_crawler_static/5152233/bg1.jpg)
![](https://csdnimg.cn/release/download_crawler_static/5152233/bg2.jpg)
![](https://csdnimg.cn/release/download_crawler_static/5152233/bg3.jpg)
![](https://csdnimg.cn/release/download_crawler_static/5152233/bg4.jpg)
![](https://csdnimg.cn/release/download_crawler_static/5152233/bg5.jpg)
剩余576页未读,继续阅读
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- vanguardsmith2014-04-07唯一最好的linux汇编入门书籍
- dashuye32014-04-25文章非常清晰,谢谢
- apang1992102014-10-18原来就是professional assembly language。下载重复了
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
- 粉丝: 0
- 资源: 1
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
- 基于元胞自动机的定向凝固模拟与金属凝固相场模拟:探讨微观组织演变与温度场耦合的研究,模拟文章核心部分:温度场、相场与溶质场的耦合模拟及其在元胞自动机、定向凝固和合金凝固中的应用分析,元胞自动机模拟,定
- 操作同花顺下单客户端下单支持(网上股票交易系统5.0)
- MPPT太阳能充电控制Matlab Simulink仿真模型搭建:原理结构、波形记录与参数详解,MPPT太阳能充电控制Matlab Simulink仿真模型搭建指南:波形记录、文献参考与原理详解,MP
- 电气安装工程施工图册-北京市建筑工程局,北京供电局编-10248061.pdf
- JESD79-5C.01-v1.31 DDR5
- Video-2024-11-02下午-文件传输思路2.wmv
- Java 面经手册,全书共计 5 章 29 节,417页11.5万字,耗时 4 个月完成 涵盖数据结构、算法逻辑、并发编程、JVM以及简历和互联网大厂面试等内容
- COMSOL手性多极子分解:原理、应用与计算技术探讨,手性多极子分解的深入研究与COMSOL模拟应用,comsol手性多极子分解 ,comsol;手性;多极子;分解,Comsol手性多极子分解技术
- 基于Yolov5与Vitis AI的模型量化及系统搭建实现食物识别在Xilinx平台上的优化应用,基于Yolov5模型的食物识别技术及其在Xilinx系统上的优化实践:模型量化编译与系统搭建之路,基于
- comsol拓扑光子晶体中的单向传输特性及其应用研究,COMSOL软件中的拓扑光子晶体实现单向传输的技术特性探究,comsol拓扑光子晶体单向传输 ,comsol; 拓扑; 光子晶体; 单向传输,Co
- 基于模糊逻辑与递推最小二乘的整车质量估计优化算法:Simulink模型实现与置信度评估,基于模糊逻辑与递推最小二乘的整车质量估计优化算法-trucksim联合仿真模型应用,整车质量估计算法,采用si
- 基于西门子PLC1200的钢板恒张力放卷收卷系统:六重要求下的精准控制与防交错策略,基于西门子PLC1200的钢板恒张力放卷收卷系统设计与实施:精确控制,确保六种要求精准执行,基于西门子PLC1200
- XR3DI Rendering Engine - Spectral Edition 2.12 光谱渲染器
- C#全面解析:与西门子Smart200 PLC的Modbus通讯项目实战,结合SQL Server数据库链接,完整例程与高清视频教学,附赠测试工具,C#上位机项目完整案例:Smart200 PLC M
- 工具变量-地级市数字关注度数据及城市数字经济关注度指标(2003-2024年).txt
- 电机转子硬线圈计算程序:高效、精确的电磁设计工具,电机转子硬线圈计算程序:高效、精确的电磁设计工具,电机转子硬线圈计算程序 ,电机转子; 硬线圈; 计算程序,电机转子硬线圈计算程序优化版
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)