assembly language for the ibm-pc second editionPDF电子书下载
- 电子书积分:20 积分如何计算积分?
- 作 者:
- 出 版 社:
- 出版年份:2222
- ISBN:
- 页数:0 页
1 Introduction 1
1.1 Introducing Assembly Language 1
Assembly Language Applications 3
Machine Language 3
1.2 Data Representation 4
Binary Numbers 4
Converting Binary to Decimal 7
Hexadecimal Numbers 7
Signed Numbers 8
Character Storage 9
1.3 Assembly Language:An Introduction 10
Assembly Language Instructions 10
A Sample Program 11
DEBUG Commands 13
The PAGE.COM Program 14
1.4 Basic Elements of Assembly Language 15
Constant 15
Statement 17
Name 18
1.5 Sample HELLO Program 19
1.6 Review Questions 20
2 Hardware and Software Architecture 22
2.1 Components of a Microcomputer 22
Video Display 22
Keyboard 23
Disk Drives 23
System Unit 23
Intel Microprocessor Family 25
2.2 System Architecture 26
Central Processing Unit(CPU) 26
Registers 28
Flags 31
Stack 32
Instruction Execution Cycle 35
2.3 System Software and Memory 35
Memory Architecture 35
DOS Initialization 36
Video Display 37
Read-Only Memory(ROM) 38
Address Calculation 38
Memory Addressing Using Registers 39
2.4 Review Questions 39
2.5 Programming Exercises 41
3 Assembly Language Fundamentals 46
3.1 Data Definition Directives 46
Define Byte(DB) 47
Define Word(DW) 49
Define Doubleword(DD) 51
DUP Operator 51
3.2 Data Transfer Instructions 52
MOV Instruction 52
Offsets 53
XCHG Instruction 55
Stack Operations 55
3.3 Arithmetic Instructions 56
INC and DEC Instructions 57
ADD Instruction 57
SUB Instruction 58
Flags Affected by ADD and SUB 58
3.4 Addressing Modes 60
Register Operand 61
Immediate Operand 61
Direct Operand 61
Indirect Operand 62
Based and Indexed Operands 63
Base-Indexed Operand 64
Base-Indexed with Displacement 64
Summing a List of Numbers 65
3.5 Program Structure 66
Memory Models 67
3.6 Review Questions 69
3.7 Programming Exercises 73
4 The Macro Assembler 76
4.1 The Assembly Process 76
A Sample Program 77
Assemble the Program 78
Link and Run the Program 79
4.2 Related Files 80
Listing File 80
Map File 81
Batch Files 82
4.3 Equates 83
The Equal-Sign Directive 83
EQU Directive 84
4.4 Operators and Expressions 85
Arithmetic Operators 85
Boolean Operators 86
OFFSET,PTR,and LABEL 86
Operands with Displacements 88
Other Assembler Operators 89
4.5 Transfer-of-Control Instructions 91
JMP Instruction 91
LOOP Instruction 93
4.6 Using the 80386 Processor 95
4.7 Debugging Workshop 96
Operand Sizes and Addressing Errors 97
4.8 Review Questions 98
4.9 Programming Exercises 103
5 Input-Output Services 106
5.1 Procedures 107
PROC and ENDP Directives 107
Sample Program:SUBS.ASM 107
Near and Far Procedures 108
5.2 Software Interrupts 111
INT Instruction 113
Device Names 115
5.3 DOS Function Calls 116
01h:Console Input With Echo 117
02h:Character Output 117
05h:Printer Output 117
06h:Direct Console Input-Output 118
07h:Direct Console Input 119
08h:Console Input Without Echo 119
09h:String Output 119
0Ah:Buffered Console Input 119
0Bh:Get Console Input Status 121
0Ch:Clear Input Buffer,Invoke Input Function 121
BIOS-Level Keyboard Input(INT 16h) 121
ASCII Control Characters 123
5.4 BIOS-Level Video Control(INT 10h) 123
Displays,Modes,and Attributes 124
127h:Set Video Mode 127
01h:Set Cursor Lines 128
02h:Set Cursor Position 129
03h:Get Cursor Position 130
05h:Set Video Page 130
06h,07h:Scroll Window Up or Down 131
08h:Read Character and Attribute 132
09h:Write Character and Attribute 133
0Ah:Write Character 133
0Fh:Get Video Mode 133
11h:Load Default ROM Fonts 134
5.5 Review Questions 134
5.6 Programming Exercises 137
6 Conditional Processing 141
6.1 Boolean and Comparison Instructions 141
The Flags Register 141
AND Instruction 142
OR Instruction 144
XOR Instruction 145
NOT Instruction 146
NEG Instruction 146
TEST Instruction 147
CMP Instruction 147
6.2 Conditional Jumps 148
Conditional Jump Instruction 149
Applications Using Conditional Jumps 151
6.3 Conditional Loops 157
LOOPZ(LOOPE) Instruction 157
LOOPNZ(LOOPNE) Instruction 158
6.4 High-Level Logic Structures 159
IF Statement 160
WHILE Structure 161
REPEAT!!UNTIL Structure 163
CASE Structure 164
Offset Table 165
6.5 Review Questions 166
6.6 Programming Exercises 169
7 Arithmetic 172
7.1 Shift and Rotate Instructions 173
SHL Instruction 173
SHR Instruction 175
SAL and SAR Instructions 176
ROL Instruction 176
ROR Instruction 177
RCL and RCR Instructions 178
7.2 Sample Applications 179
Shifting Multiple Bytes 179
Multiplication and Division 180
Display a Number in ASCⅡ Binary 181
Isolate a Bit String 182
7.3 Multiple Addition and Subtraction 183
ADC Instruction 183
SBB Instruction 185
7.4 Signed Arithmetic 186
7.5 Multiplication and Division 187
MUL and IMUL Instructions 187
DIV and IDIV Instructions 189
Divide Overflow 190
7.6 ASCⅡ Arithmetic 191
AAA Instruction 193
AAS Instruction 195
AAM Instruction 196
AAD Instruction 197
7.7 Packed Decimal Arithmetic 197
DAA Instruction 198
DAS Instruction 198
BCD Addition Example 198
7.8 Review Questions 201
7.9 Programming Exercises 204
8 Numeric Conversions and Libraries 208
8.1 Character Translation Using XLAT 209
The XLAT Instruction 209
Character Filtering 210
Character Encoding 210
8.2 Binary to ASCⅡ Conversion 213
The WRITEINT Procedure 214
8.3 ASCⅡ to Binary Conversion 218
The READINT Procedure 218
8.4 Separately Assembled Modules 222
EXTRN Directive 223
PUBLIC Directive 224
Calling DISPLAYSTR from Another Module 224
8.5 Creating External Subroutines 226
Individual Subroutine Descriptions 227
A Test Program 236
More About the Linker 237
8.6 Stack Parameters 238
Recursion 239
8.7 Review Questions 242
8.8 Programmming Exercises 244
9 String Processing 251
9.1 String Storage Methods 252
9.2 String Primitive Instructions 253
MOVS(Move String) 256
CMPS(Compare Strings) 258
SCAS(Scan String) 260
STOS(Store in String) 262
LODS(Load String) 263
9.3 A Library of String Routines 263
READSTRING Procedure 264
STRCHR Procedure 265
STRCOMP Procedure 266
STRCOPY Procedure 267
STRDEL Procedure 268
STRLEN Procedure 269
STRSTR Procedure 270
STRUPR Procedure 271
WRITESTRING Procedure 272
9.4 Creating a Link Library 272
9.5 Application: String Library Demo Program 275
9.6 Review Questions 278
9.7 Programming Exercises 280
10 Macros and Structures 285
10.1 Introduction 285
Declaring and Calling Macros 287
Passing Parameters 288
Nested Macros 290
LOCAL Directive 291
10.2 Special Techniques 292
Macros Calling Procedures 292
Conditional-Assembly Directives 293
EXITM Directive 295
10.3 Macro Operators 297
10.4 A Macro Library 299
10.5 Advanced MACRO Usage 303
Defining Repeat Blocks 303
Additional Tips 307
10.6 Advanced Operators and Directives 313
Type Operators 313
STRUC Directive 314
RECORD Directive 316
10.7 Review Questions 320
10.8 Programming Exercises 323
11 Disk Storage 327
11.1 Disk Storage Fundamentals 328
Physical and Logical Chacteristics 328
Types of Disks 329
Disk Formats 330
Disk Directory 331
Directory Format 332
Sample Disk Directory 334
File Allocation Table(FAT) 335
Reading and Writing Disk Sectors 336
11.2 Application: Sector Display Program 337
11.3 Application: Cluster Display Program 340
11.4 System-Level File Functions 345
DOS Error Codes 345
Displaying DOS Error Messages 346
DOS Error Message Handler 347
File Specifications 350
11.5 Reading the DOS Command Tail 350
11.6 Drive and Directory Manipulation 352
Set Default Disk Drive(0Eh) 353
Get Default Disk Drive(19h) 353
Get Disk Free Space(36h) 353
Get Current Directory Path(47h) 354
Set Current Directory(3Bh) 354
Create Subdirectory(39h) 355
Remove Subdirectory(3Ah) 355
Get Device Parameters(44h) 355
11.7 File Manipulation 357
Get/Set File Attribute(43h) 357
Delete File(41h) 359
Rename File(56h) 360
Get/Set File Date and Time(57h) 360
Find First Matching File(4Eh) 361
Find Next Matching File(4Fh) 362
Set Disk Transfer Address(1Ah) 362
11.8 Application:Display Filenames and Dates 363
11.9 Review Questions 366
11.10 Programmming Exercises 368
12 File Processing 373
12.1 Standard DOS File Functions 374
Create File(3Ch) 374
Open File(3Dh) 376
Close File Handle(3Eh) 377
Read from File or Device(3Fh) 377
Write to File or Device(40h) 378
12.2 Application:Create a Text File 379
12.3 Application:List a Text File 383
The File Listing Program 385
12.4 Application:Display a Student Information File 388
Fixed-Length Record Processing 388
The Student Information File 389
The Student Information Program 390
12.5 Random File Access 395
Move File Pointer(42h) 396
12.6 Indexing the Student Information File 398
The Student Index Program 398
12.7 Review Questions 406
12.8 Programmming Exercises 408
13 High-Level Linking 412
13.1 General Conventions 412
13.2 Linking to Turbo Pascal 414
Sample Procedure 415
Passing Arguments by Value 418
Passing Arguments by Reference 420
Example:The COUN_CHAR Function 421
Identifiers Declared in the Pascal Module 423
13.3 Turbo Built-In Assembler(BASM) 426
Turbo Pascal BASM Syntax 426
13.4 Inline Statements and Directives 429
13.5 Linking to Turbo C 431
Compiling and Linking 431
Segment Names and Calling Conventions 432
Calling the ADDEM Function 433
File Encryption Example 435
13.6 Review Questions 437
13.7 Programming Exercises 439
14 Advanced Topics Ⅰ 444
14.1 Completing the Instruction Set 444
Loading Pointers 445
Indirect Jumps and Calls 446
Loading Far Pointers 447
Interrupt Control Instructions 449
Processor Control Instructions 450
Accessing Input-Output Ports 451
Flag Manipulation Instructions 453
14.2 Defining Segments 454
The SEGMENT and ENDS Directives 455
The ASSUME Directive 458
Segment Override Operator 460
Combining Segments 460
The GROUP Directive 461
Simplified Segment Directives 464
14.3 Running Programs Under DOS 465
COM Programs 466
EXE Programs 467
Memory Models 468
Configuring CONFIG.SYS 469
14.4 Review Questions 470
14.5 Programming Exercises 473
15 Advanced Topics Ⅱ 477
15.1 System Hardware 477
Real-Time Clock 478
CPU 478
Calculating Instruction Timings 480
Loop Example 482
Loop Example in Pascal 484
15.2 Instruction Encoding 485
Single-Byte Instructions 486
Immediate Operands 486
Register-Mode Instructions 487
Memory-Mode Instructions 488
15.3 Dynamic Memory Allocation 490
Modify Memory Blocks 492
Allocate Memory 492
Release Allocated Memory 493
15.4 Interrupt Handling 493
Replacing Interrupt Vectors 496
Memory-Resident Programs 497
Application:The NO_RESET Program 498
15.5 Defining Real Numbers 503
Define Doubleword(DD) 504
Define Quadword(DQ) 504
Define Tenbyte(DT) 505
15.6 Intel 80×87 Math Coprocessor 505
Instruction Formats 506
Evaluating an Expression 508
Application:Payroll Calculation Program 509
15.7 Review Questions 513
15.8 Programmming Exercises 514
Appendixes 519
A.Binary and Hexadecimal Tutorial 519
B.Using DEBUG 533
C.Microsoft CodeView 547
D.Borland Turbo Debugger 555
E.Guide to the Companion Diskette 562
F.MASM/TASM Reserved Words 566
G.BIOS and DOS Interrupts 569
H.Intel 8086/8088 Instruction Set 579
I.Answers to Selected Review Questions 603
Index 617