没有合适的资源?快使用搜索试试~ 我知道了~
首页《汇编语言程序艺术》英文原版:探索计算机科学的经典教程
"《汇编语言程序艺术》是一本经典的计算机科学著作,旨在教授汇编语言,将汇编视为一种艺术。这本书以PDF形式提供,适合对汇编语言感兴趣的读者学习。"
本书分为五个部分,详细介绍了汇编语言的基础和高级概念。
第一部分主要涵盖了基础内容:
1. 数据表示(Data Representation):讲解了二进制、八进制、十六进制和ASCII码等数据表示方式,以及它们在计算机中的应用。
2. 布尔代数(Boolean Algebra):介绍了布尔逻辑运算,如与、或、非、异或,这些是理解计算机硬件和逻辑门的基础。
3. 系统组织(System Organization):阐述了计算机体系结构的基本原理,包括CPU、内存和外设之间的交互。
4. 内存布局和访问(Memory Layout and Access):讨论了内存地址、内存空间分配以及如何通过指令访问内存。
第二部分深入到编程实践:
5. 变量和数据结构(Variables and Data Structures):讲解了如何在汇编语言中声明和操作变量,以及如何构建和操作基本的数据结构。
6. 80x86指令集(The 80x86 Instruction Set):详细介绍了Intel 80x86系列处理器的指令系统,包括各种运算、转移、输入/输出等指令。
7. UCR标准库(The UCR Standard Library):介绍了用于简化汇编编程的实用函数和宏。
8. MASM:指令与伪指令(MASM: Directives & Pseudo-Opcodes):讲解了Microsoft Macro Assembler (MASM)的使用,包括汇编指令和MASM特有的伪指令。
9. 算术和逻辑操作(Arithmetic and Logical Operations):详述了算术和逻辑运算的实现,包括整数和浮点数运算。
10. 控制结构(Control Structures):涵盖了条件分支、循环和跳转等控制程序流程的结构。
11. 过程和函数(Procedures and Functions):解释了如何定义和调用子程序,以及参数传递机制。
第三部分探讨了更高级的主题:
12. 进程:高级话题(Procedures: Advanced Topics):深入研究了过程的实现,包括递归、堆栈和异常处理。
13. MS-DOS、PC-BIOS和文件I/O(MS-DOS, PC-BIOS, and File I/O):讲解了如何与DOS操作系统交互,进行磁盘操作和文件读写。
14. 浮点运算(Floating Point Arithmetic):介绍了如何在汇编语言中处理浮点数运算,涉及x87浮点单元。
15. 字符串和字符集(Strings and Character Sets):探讨了字符串处理技术,以及ASCII和其他字符编码系统。
16. 模式匹配(Pattern Matching):介绍了如何在汇编语言中实现模式匹配算法。
第四部分涉及系统级编程:
17. 中断、陷阱和异常(Interrupts, Traps, and Exceptions):解释了中断处理机制,包括硬件中断和软件中断。
18. 常驻程序(Resident Programs):讲解了如何编写在内存中常驻的程序,以及如何管理内存资源。
19. 进程、协程和并发(Processes, Coroutines, and Concurrency):介绍了并发编程的概念,包括进程间的通信和同步。
第五部分专注于PC硬件接口:
20. PC键盘(The PC Keyboard):详细分析了如何与PC键盘交互,包括扫描码和事件处理。
21. PC并行端口(The PC Parallel Ports):讲解了并行端口的工作原理和编程方法。
22. PC串行端口(The PC Serial Ports):介绍了如何使用串行端口进行通信,包括波特率、数据位、停止位和校验位的设置。
通过这本书,读者不仅可以掌握汇编语言的基础知识,还能深入了解计算机系统的工作原理,以及如何直接与硬件进行交互。无论是对于计算机科学家、软件工程师还是对底层编程感兴趣的爱好者,这都是一本不可多得的资源。
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页未读,继续阅读
2017-09-21 上传
2021-10-01 上传
2010-01-20 上传
2010-06-19 上传
2010-07-11 上传
2019-11-15 上传
2013-09-15 上传
2014-05-06 上传
twilightmaomao
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 火炬连体网络在MNIST的2D嵌入实现示例
- Angular插件增强Application Insights JavaScript SDK功能
- 实时三维重建:InfiniTAM的ros驱动应用
- Spring与Mybatis整合的配置与实践
- Vozy前端技术测试深入体验与模板参考
- React应用实现语音转文字功能介绍
- PHPMailer-6.6.4: PHP邮件收发类库的详细介绍
- Felineboard:为猫主人设计的交互式仪表板
- PGRFileManager:功能强大的开源Ajax文件管理器
- Pytest-Html定制测试报告与源代码封装教程
- Angular开发与部署指南:从创建到测试
- BASIC-BINARY-IPC系统:进程间通信的非阻塞接口
- LTK3D: Common Lisp中的基础3D图形实现
- Timer-Counter-Lister:官方源代码及更新发布
- Galaxia REST API:面向地球问题的解决方案
- Node.js模块:随机动物实例教程与源码解析
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功