没有合适的资源?快使用搜索试试~ 我知道了~
首页深入理解Intel x86汇编艺术
深入理解Intel x86汇编艺术
下载需积分: 9 | PDF格式 | 3.82MB |
更新于2024-07-24
| 101 浏览量 | 3 下载量 举报
《英特尔x86汇编艺术》是一本深入探讨Intel x86架构的高级教材,它涵盖了从基础数据表示到复杂系统行为的广泛主题。本书共分为五个主要部分,每个部分都专注于不同的核心概念和技术。
第一部分:数据与系统结构
- 第一章:数据表示 - 介绍计算机如何存储和处理不同类型的数据,包括整数、浮点数和字符,这对于理解汇编语言中的操作至关重要。
- 第三章:系统组织 - 讨论了处理器架构,内存布局,以及CPU与外设之间的通信方式,这部分对于理解硬件和软件交互的基础非常关键。
第二部分:指令集与编程工具
- 第五章:变量和数据结构 - 学习如何创建和管理程序中的数据结构,如数组和结构体,是编写有效代码的基础。
- 第六章:80x86指令集 - 详细介绍了x86指令集,包括寻址模式、运算指令和控制转移,这是实际编写汇编代码的核心内容。
- 第八章:MASM:指令和伪指令 - 阐述Microsoft Macro Assembler(MASM)工具,以及如何使用这些指令和伪指令来实现高级功能。
第三部分:进阶主题与操作系统交互
- 第十二章:高级过程与函数 - 深入讲解过程调用、函数设计和参数传递等高级概念,以及在多任务环境中的应用。
- 第十三章:MS-DOS、PC-BIOS和文件I/O - 描述早期操作系统的基本工作原理,以及如何通过汇编与之交互进行文件操作。
第四部分:中断、异常处理与并发
- 第十七章:中断、陷阱与异常 - 学习处理器如何响应中断和处理异常情况,这对理解和调试程序错误非常重要。
- 第十九章:进程、协程和并发 - 探讨并发编程在x86架构下的实现,包括线程管理和同步机制。
第五部分:硬件接口
- 第二十章:PC键盘 - 讨论如何通过汇编操作硬件输入设备,这在底层编程中不可或缺。
- 第二十一章:PC并行和串行端口 - 学习如何利用硬件端口进行数据传输,扩展计算机的功能。
《艺术》这本书不仅适合对汇编语言有深厚兴趣的专业程序员,也适合希望深入了解底层计算机工作原理的开发者。无论是初学者还是经验丰富的开发者,都能从中收获实用的知识和技巧,提升在x86平台上的编程能力。

Page xvi
13.4.8 Fwrite ....................................................................................................................753
13.4.9 Redirecting I/O Through the StdLib File I/O Routines ........................................753
13.4.10 A File I/O Example .............................................................................................755
13.5 Sample Program ..............................................................................................................758
13.6 Laboratory Exercises .......................................................................................................763
13.7 Programming Projects .....................................................................................................768
13.8 Summary ..........................................................................................................................768
13.9 Questions .........................................................................................................................770
Chapter 14 Floating Point Arithmetic .......................................................................... 771
14.0 Chapter Overview ...........................................................................................................771
14.1 The Mathematics of Floating Point Arithmetic ...............................................................771
14.2 IEEE Floating Point Formats ............................................................................................774
14.3 The UCR Standard Library Floating Point Routines ........................................................777
14.3.1 Load and Store Routines .......................................................................................778
14.3.2 Integer/Floating Point Conversion .......................................................................779
14.3.3 Floating Point Arithmetic ......................................................................................780
14.3.4 Float/Text Conversion and Printff ........................................................................780
14.4 The 80x87 Floating Point Coprocessors .........................................................................781
14.4.1 FPU Registers ........................................................................................................781
14.4.1.1 The FPU Data Registers .............................................................................. 782
14.4.1.2 The FPU Control Register ........................................................................... 782
14.4.1.3 The FPU Status Register .............................................................................. 785
14.4.2 FPU Data Types ....................................................................................................788
14.4.3 The FPU Instruction Set ........................................................................................789
14.4.4 FPU Data Movement Instructions ........................................................................789
14.4.4.1 The FLD Instruction .................................................................................... 789
14.4.4.2 The FST and FSTP Instructions ................................................................... 790
14.4.4.3 The FXCH Instruction ................................................................................. 790
14.4.5 Conversions ..........................................................................................................791
14.4.5.1 The FILD Instruction ................................................................................... 791
14.4.5.2 The FIST and FISTP Instructions ................................................................ 791
14.4.5.3 The FBLD and FBSTP Instructions ............................................................. 792
14.4.6 Arithmetic Instructions .........................................................................................792
14.4.6.1 The FADD and FADDP Instructions .......................................................... 792
14.4.6.2 The FSUB, FSUBP, FSUBR, and FSUBRP Instructions ............................... 793
14.4.6.3 The FMUL and FMULP Instructions ............................................................ 794
14.4.6.4 The FDIV, FDIVP, FDIVR, and FDIVRP Instructions ................................. 794
14.4.6.5 The FSQRT Instruction ............................................................................... 795
14.4.6.6 The FSCALE Instruction .............................................................................. 795
14.4.6.7 The FPREM and FPREM1 Instructions ........................................................ 795
14.4.6.8 The FRNDINT Instruction ........................................................................... 796
14.4.6.9 The FXTRACT Instruction ........................................................................... 796
14.4.6.10 The FABS Instruction ................................................................................ 796
14.4.6.11 The FCHS Instruction ................................................................................ 797
14.4.7 Comparison Instructions ......................................................................................797
14.4.7.1 The FCOM, FCOMP, and FCOMPP Instructions ........................................ 797
14.4.7.2 The FUCOM, FUCOMP, and FUCOMPP Instructions ................................ 798
14.4.7.3 The FTST Instruction .................................................................................. 798
14.4.7.4 The FXAM Instruction ................................................................................. 798
14.4.8 Constant Instructions ............................................................................................798

The Art of Assembly Language
Page xvii
14.4.9 Transcendental Instructions ................................................................................799
14.4.9.1 The F2XM1 Instruction ............................................................................... 799
14.4.9.2 The FSIN, FCOS, and FSINCOS Instructions ............................................. 799
14.4.9.3 The FPTAN Instruction .............................................................................. 799
14.4.9.4 The FPATAN Instruction ............................................................................ 800
14.4.9.5 The FYL2X and FYL2XP1 Instructions ....................................................... 800
14.4.10 Miscellaneous instructions ................................................................................. 800
14.4.10.1 The FINIT and FNINIT Instructions ......................................................... 800
14.4.10.2 The FWAIT Instruction ............................................................................. 801
14.4.10.3 The FLDCW and FSTCW Instructions ...................................................... 801
14.4.10.4 The FCLEX and FNCLEX Instructions ...................................................... 801
14.4.10.5 The FLDENV, FSTENV, and FNSTENV Instructions ................................ 801
14.4.10.6 The FSAVE, FNSAVE, and FRSTOR Instructions ..................................... 802
14.4.10.7 The FSTSW and FNSTSW Instructions ..................................................... 803
14.4.10.8 The FINCSTP and FDECSTP Instructions ................................................ 803
14.4.10.9 The FNOP Instruction .............................................................................. 803
14.4.10.10 The FFREE Instruction ............................................................................ 803
14.4.11 Integer Operations ............................................................................................. 803
14.5 Sample Program: Additional Trigonometric Functions ................................................. 804
14.6 Laboratory Exercises .......................................................................................................810
14.6.1 FPU vs StdLib Accuracy ....................................................................................... 811
14.7 Programming Projects ....................................................................................................814
14.8 Summary ......................................................................................................................... 814
14.9 Questions ........................................................................................................................ 817
Chapter 15 Strings and Character Sets ......................................................................... 819
15.0 Chapter Overview ........................................................................................................... 819
15.1 The 80x86 String Instructions ......................................................................................... 819
15.1.1 How the String Instructions Operate ...................................................................819
15.1.2 The REP/REPE/REPZ and REPNZ/REPNE Prefixes ............................................. 820
15.1.3 The Direction Flag ............................................................................................... 821
15.1.4 The MOVS Instruction ......................................................................................... 822
15.1.5 The CMPS Instruction .......................................................................................... 826
15.1.6 The SCAS Instruction ........................................................................................... 828
15.1.7 The STOS Instruction ........................................................................................... 828
15.1.8 The LODS Instruction .......................................................................................... 829
15.1.9 Building Complex String Functions from LODS and STOS ................................ 830
15.1.10 Prefixes and the String Instructions ...................................................................830
15.2 Character Strings ............................................................................................................. 831
15.2.1 Types of Strings .................................................................................................... 831
15.2.2 String Assignment ................................................................................................ 832
15.2.3 String Comparison ............................................................................................... 834
15.3 Character String Functions .............................................................................................835
15.3.1 Substr .................................................................................................................... 835
15.3.2 Index ................................................................................................................... 838
15.3.3 Repeat .................................................................................................................840
15.3.4 Insert ...................................................................................................................841
15.3.5 Delete ................................................................................................................... 843
15.3.6 Concatenation ...................................................................................................... 844
15.4 String Functions in the UCR Standard Library ................................................................845

Page xviii
15.4.1 StrBDel, StrBDelm ................................................................................................846
15.4.2 Strcat, Strcatl, Strcatm, Strcatml ............................................................................847
15.4.3 Strchr .....................................................................................................................848
15.4.4 Strcmp, Strcmpl, Stricmp, Stricmpl .......................................................................848
15.4.5 Strcpy, Strcpyl, Strdup, Strdupl .............................................................................849
15.4.6 Strdel, Strdelm .......................................................................................................850
15.4.7 Strins, Strinsl, Strinsm, Strinsml ............................................................................851
15.4.8 Strlen .....................................................................................................................852
15.4.9 Strlwr, Strlwrm, Strupr, Struprm ...........................................................................852
15.4.10 Strrev, Strrevm .....................................................................................................853
15.4.11 Strset, Strsetm ......................................................................................................853
15.4.12 Strspan, Strspanl, Strcspan, Strcspanl .................................................................854
15.4.13 Strstr, Strstrl .........................................................................................................855
15.4.14 Strtrim, Strtrimm ..................................................................................................855
15.4.15 Other String Routines in the UCR Standard Library ...........................................856
15.5 The Character Set Routines in the UCR Standard Library ...............................................856
15.6 Using the String Instructions on Other Data Types ........................................................859
15.6.1 Multi-precision Integer Strings .............................................................................859
15.6.2 Dealing with Whole Arrays and Records .............................................................860
15.7 Sample Programs .............................................................................................................860
15.7.1 Find.asm ................................................................................................................860
15.7.2 StrDemo.asm .........................................................................................................862
15.7.3 Fcmp.asm ..............................................................................................................865
15.8 Laboratory Exercises .......................................................................................................868
15.8.1 MOVS Performance Exercise #1 ...........................................................................868
15.8.2 MOVS Performance Exercise #2 ...........................................................................870
15.8.3 Memory Performance Exercise ............................................................................872
15.8.4 The Performance of Length-Prefixed vs. Zero-Terminated Strings .....................874
15.9 Programming Projects .....................................................................................................878
15.10 Summary ........................................................................................................................878
15.11 Questions .......................................................................................................................881
Chapter 16 Pattern Matching ....................................................................................... 883
16.1 An Introduction to Formal Language (Automata) Theory .............................................883
16.1.1 Machines vs. Languages .......................................................................................883
16.1.2 Regular Languages ................................................................................................884
16.1.2.1 Regular Expressions .................................................................................... 885
16.1.2.2 Nondeterministic Finite State Automata (NFAs) ........................................ 887
16.1.2.3 Converting Regular Expressions to NFAs ................................................... 888
16.1.2.4 Converting an NFA to Assembly Language ................................................ 890
16.1.2.5 Deterministic Finite State Automata (DFAs) .............................................. 893
16.1.2.6 Converting a DFA to Assembly Language .................................................. 895
16.1.3 Context Free Languages .......................................................................................900
16.1.4 Eliminating Left Recursion and Left Factoring CFGs ...........................................903
16.1.5 Converting REs to CFGs .......................................................................................905
16.1.6 Converting CFGs to Assembly Language .............................................................905
16.1.7 Some Final Comments on CFGs ...........................................................................912
16.1.8 Beyond Context Free Languages .........................................................................912
16.2 The UCR Standard Library Pattern Matching Routines ...................................................913
16.3 The Standard Library Pattern Matching Functions .........................................................914

The Art of Assembly Language
Page xix
16.3.1 Spancset ............................................................................................................... 914
16.3.2 Brkcset .................................................................................................................. 915
16.3.3 Anycset ................................................................................................................. 915
16.3.4 Notanycset ........................................................................................................... 916
16.3.5 MatchStr ................................................................................................................ 916
16.3.6 MatchiStr ............................................................................................................... 916
16.3.7 MatchToStr ........................................................................................................... 917
16.3.8 MatchChar ............................................................................................................ 917
16.3.9 MatchToChar ........................................................................................................918
16.3.10 MatchChars ......................................................................................................... 918
16.3.11 MatchToPat ........................................................................................................ 918
16.3.12 EOS ..................................................................................................................... 919
16.3.13 ARB ..................................................................................................................... 919
16.3.14 ARBNUM ............................................................................................................ 920
16.3.15 Skip ..................................................................................................................... 920
16.3.16 Pos ...................................................................................................................... 921
16.3.17 RPos ....................................................................................................................921
16.3.18 GotoPos ..............................................................................................................921
16.3.19 RGotoPos ...........................................................................................................922
16.3.20 SL_Match2 .......................................................................................................... 922
16.4 Designing Your Own Pattern Matching Routines ..........................................................922
16.5 Extracting Substrings from Matched Patterns ................................................................925
16.6 Semantic Rules and Actions ............................................................................................ 929
16.7 Constructing Patterns for the MATCH Routine .............................................................. 933
16.8 Some Sample Pattern Matching Applications ................................................................ 935
16.8.1 Converting Written Numbers to Integers ............................................................935
16.8.2 Processing Dates .................................................................................................. 941
16.8.3 Evaluating Arithmetic Expressions ...................................................................... 948
16.8.4 A Tiny Assembler ................................................................................................. 953
16.8.5 The “MADVENTURE” Game ................................................................................963
16.9 Laboratory Exercises .......................................................................................................979
16.9.1 Checking for Stack Overflow (Infinite Loops) .................................................... 979
16.9.2 Printing Diagnostic Messages from a Pattern ......................................................984
16.10 Programming Projects ................................................................................................... 988
16.11 Summary .......................................................................................................................988
16.12 Questions ...................................................................................................................... 991
Section Four: ............................................................................................................... 993
Advanced Assembly Language Programming ...................................................................... 993
Chapter 17 Interrupts, Traps, and Exceptions ............................................................ 995
17.1 80x86 Interrupt Structure and Interrupt Service Routines (ISRs) ..................................996
17.2 Traps ............................................................................................................................... 999
17.3 Exceptions ......................................................................................................................1000
17.3.1 Divide Error Exception (INT 0) ........................................................................... 1000
17.3.2 Single Step (Trace) Exception (INT 1) ................................................................1000
17.3.3 Breakpoint Exception (INT 3) ............................................................................. 1001
17.3.4 Overflow Exception (INT 4/INTO) .....................................................................1001
17.3.5 Bounds Exception (INT 5/BOUND) ...................................................................1001
17.3.6 Invalid Opcode Exception (INT 6) ...................................................................... 1004

Page xx
17.3.7 Coprocessor Not Available (INT 7) ......................................................................1004
17.4 Hardware Interrupts ........................................................................................................1004
17.4.1 The 8259A Programmable Interrupt Controller (PIC) .........................................1005
17.4.2 The Timer Interrupt (INT 8) .................................................................................1007
17.4.3 The Keyboard Interrupt (INT 9) ...........................................................................1008
17.4.4 The Serial Port Interrupts (INT 0Bh and INT 0Ch) ..............................................1008
17.4.5 The Parallel Port Interrupts (INT 0Dh and INT 0Fh) ...........................................1008
17.4.6 The Diskette and Hard Drive Interrupts (INT 0Eh and INT 76h) ........................1009
17.4.7 The Real-Time Clock Interrupt (INT 70h) ............................................................1009
17.4.8 The FPU Interrupt (INT 75h) ................................................................................1009
17.4.9 Nonmaskable Interrupts (INT 2) ..........................................................................1009
17.4.10 Other Interrupts ..................................................................................................1009
17.5 Chaining Interrupt Service Routines ...............................................................................1010
17.6 Reentrancy Problems ......................................................................................................1012
17.7 The Efficiency of an Interrupt Driven System ................................................................1014
17.7.1 Interrupt Driven I/O vs. Polling ...........................................................................1014
17.7.2 Interrupt Service Time ..........................................................................................1015
17.7.3 Interrupt Latency ..................................................................................................1016
17.7.4 Prioritized Interrupts .............................................................................................1020
17.8 Debugging ISRs ...............................................................................................................1020
17.9 Summary ..........................................................................................................................1021
Chapter 18 Resident Programs ................................................................................... 1025
18.1 DOS Memory Usage and TSRs ........................................................................................1025
18.2 Active vs. Passive TSRs ....................................................................................................1029
18.3 Reentrancy .......................................................................................................................1032
18.3.1 Reentrancy Problems with DOS ...........................................................................1032
18.3.2 Reentrancy Problems with BIOS ..........................................................................1033
18.3.3 Reentrancy Problems with Other Code ...............................................................1034
18.4 The Multiplex Interrupt (INT 2Fh) ..................................................................................1034
18.5 Installing a TSR ................................................................................................................1035
18.6 Removing a TSR ...............................................................................................................1037
18.7 Other DOS Related Issues ...............................................................................................1039
18.8 A Keyboard Monitor TSR ................................................................................................1041
18.9 Semiresident Programs ....................................................................................................1055
18.10 Summary ........................................................................................................................1064
Chapter 19 Processes, Coroutines, and Concurrency ............................................... 1065
19.1 DOS Processes .................................................................................................................1065
19.1.1 Child Processes in DOS ........................................................................................1065
19.1.1.1 Load and Execute ....................................................................................... 1066
19.1.1.2 Load Program .............................................................................................. 1068
19.1.1.3 Loading Overlays ........................................................................................ 1069
19.1.1.4 Terminating a Process ................................................................................. 1069
19.1.1.5 Obtaining the Child Process Return Code ................................................. 1070
19.1.2 Exception Handling in DOS: The Break Handler ................................................1070
19.1.3 Exception Handling in DOS: The Critical Error Handler .....................................1071
19.1.4 Exception Handling in DOS: Traps ......................................................................1075
19.1.5 Redirection of I/O for Child Processes ................................................................1075
剩余1425页未读,继续阅读
相关推荐










gekun0823
- 粉丝: 0
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助

最新资源
- iOS11以上版本实现自带二维码扫描功能及相册扫描
- 朗朗V29万能液晶主板全套数据与特显摇控新程序包
- C#实现CAD参数文件批量插入操作桌面程序
- Swift教程:使用Storyboard开发天气预报APP
- 提升ESPN玩家链接体验的Better ESPN Player Links-crx插件
- VB刷PV源码:增强网页访问量的学习工具
- 快速生成RRDTool示例数据集的bash脚本介绍
- 深入解析brain-3.0与taro3.0结合使用技巧
- Android架构模式实践:MVP与MVVP模式解析
- iOS引导页实现与TableviewCell配置
- 高德地图定位与周边POI搜索测试分享
- Mocha与Karma增量测试样板快速入门指南
- 掌握Java打包全攻略:jar到exe,附教程
- Annot-E-crx插件:网页注释工具的扩展程序
- 音像技术在多媒体应用中的发展与探索
- 中国海洋大学软件工程期末试卷参考解析
安全验证
文档复制为VIP权益,开通VIP直接复制
