《IBM PC汇编语言与程序设计 第4版》PDF下载

  • 购买积分:18 如何计算积分?
  • 作  者:(美)(P.埃布尔)Peter Abel著
  • 出 版 社:北京:清华大学出版社
  • 出版年份:1998
  • ISBN:7302028303
  • 页数:606 页
图书介绍:内容简介本书目的是帮助读者学习用汇编语言进行程序设计,首先简明地介绍硬件和软件,然后介绍编程所必需的指令,特别重视用例清晰。第4版与前几版相比:加强对Intel80486及其后继机型的介绍,有更多的实例和练习,而且较早地引入了中断操作,介绍了最新的汇编程序版本,对全书作了大面积调整和修订,每章后的问题经过修订和增补。全书分7部分:PC机硬、软件基础;汇编语言基础;屏幕操作与键盘操作;数据处理;先进的输入/输出;高级程序设计;有关BIOS数据区程序中断,伪操作,指令系统的参考资料;书后附有每章后部分问题的答案。

Part A Fundamentals of PC Hardware and Software 1

1 BASIC FEATURES OF PC HARDWARE 1

Introduction 1

Bits and Bytes 1

Binary Numbers 3

Hexadecimal Representation 6

ASCII Code 7

The Processor 7

Internal Memory 9

Segments and Addressing 11

Registers 13

Key Points 17

Questions 18

2 REQUIREMENTS FOR USING PC SOFTWARE 20

Introduction 20

Features of the Operating System 20

The Boot Process 21

Input-Output Interface 22

The System Program Loader 22

The Stack 23

Addressing of Instructions and Data 25

Instruction Operands 27

Key Points 27

Questions 28

3 EXECUTING COMPUTER INSTRUCTIONS 29

Introduction 29

Using the DEBUG Program 30

Viewing Memory Locations 31

Machine Language Example Ⅰ:Immediate Data 34

Machine Language Example Ⅱ:Defined Data 38

An Assembly Language Example 41

Using the INT Instruction 42

Saving a Program from Within DEBUG 45

Using the PTR Operator 45

Key Points 46

Questions 47

Part B Fundamentals of Assembly Language 49

4 REQUIREMENTS FOR CODING IN ASSEMBLY LANGUAGE 49

Introduction 49

Assemblers and Compilers 50

Program Comments 50

Reserved Words 51

Identifiers 51

Statements 52

Directives 53

Instructions for Initializing a Program 57

Instructions for Ending Program Execution 59

Example of a Source Program 59

Initializing for Protected Mode 60

Simplified Segment Directives 61

Data Definition 62

Directives for Defining Data 65

The EQu Directive 69

Key Points 70

Questions 71

5 ASSEMBLING,LINKING,AND EXECUTING A PROGRAM 73

Introduction 73

Preparing a Program for Execution 73

Assembling a Source Program 74

Using Conventional Segment Definitions 76

Using Simplified Segment Directives 81

Two-Pass Assembler 83

Linking an Object Program 83

Executing a Program 86

Cross-Reference Listing 86

Error Diagnostics 87

The Assembler Location Counter 89

Key Points 89

Questions 89

6 SYMBOLIC INSTRUCTIONS AND ADDRESSING 91

Introduction 91

The Symbolic Instruction Set 91

Instruction Operands 94

The Mov Instruction 97

Move-and-Fill Instructions 98

Immediate Operands 99

The XCHG Instruction 100

The LEA Instruction 101

The INC and DEC Instructions 101

Extended Move Operations 101

The INT Instruction 103

Aligning Data Addresses 104

Near and Far Addresses 104

The Segment Override Prefix 105

Key Points 105

Questions 106

7 WRITING.COM PROGRAMS 108

Introduction 108

Differences Between an.EXE and a.COM Program 108

Converting into.CoM Format 109

Example of a.CoM Program 110

The.COM Stack 111

Debugging Tips 112

Key Points 112

Questions 113

8 PROGRAMMING REQUIREMENTS FOR LOGIC AND CONTROL 114

Introduction 114

Short,Near,and Far Addresses 115

Instruction Labels 115

The JMP Instruction 116

The LOOP Instruction 118

The Flags Register 119

The CMP Instruction 120

Conditional Jump Instructions 121

Calling Procedures 123

Effect of Program Execution on the Stack 126

Boolean Operations 127

Program:Changing Uppercase to Lowercase 129

Shifting Bits 130

Rotating Bits 132

Jump Tables 134

Organizing a Program 136

Key Points 137

Questions 137

Part C Screen and Keyboard Operations 139

9 INTRODUCTION TO SCREEN AND KEYBOARD PROCESSING 139

Introduction 139

The Screen 140

Setting the Cursor 140

Clearing the Screen 141

INT 21H Function O9H for Screen Display 142

TNT 21H Function OAH for Keyboard Input 144

Program:Accepting and Displaying Names 145

Using Control Characters in a Screen Display 149

INT 21H Function O2H for Screen Display 150

File Handles 150

INT 2IH Function 4OH for Screen Display 151

INT 2IH Function 3FH for Keyboard Input 152

Key Points 154

Questions 154

10 ADVANCED FEATURES OF SCREEN PROCESSING 156

Introduction 156

Video Adapters 157

Setting the Video Mode 157

Using Text Mode 158

Screen Pages 161

Using INT IOH for Text Mode 161

Program:Displaying the ASCII Character Set 167

ASCII Characters for Boxes and Menus 170

Program:Blinking,Reverse Video,and Scrolling 171

Direct Video Display 173

Using Graphics Mode 175

INT IoH for Graphics 177

Program:Setting and Displaying Graphics Mode 180

Determining the Type of Video Adapter 182

Key Points 182

Questions 183

11 ADVANCED FEATURES OF KEYBOARD PROCESSING 185

Introduction 185

The Keyboard 186

Keyboard Shift Status 186

The Keyboard Buffer 187

Using INT 21H for Keyboard Input 188

Using INT 16H for Keyboard Input 189

Extended Function Keys and Scan Codes 191

Program:Selecting from a Menu 193

BIOS INT O9H and the Keyboard Buffer 197

Keying in the Full ASCII Character Set 201

Key Points 201

Questions 202

Part D Data Manipulation 203

12 PROCESSING STRING DATA 203

Introduction 203

Features of String Operations 204

REP:Repeat String Prefix 204

MOVS:Move String Instruction 205

LODS:Load String Instruction 207

STOS:Store String Instruction 208

Program:Using LoDs and STOS to Transfer Data 209

CMPS:Compare String Instruction 211

SCAS:Scan String Instruction 213

Example:Using Scan and Replace 214

Alternative Coding for String Instructions 214

Duplicating a Pattern 215

Program:Right Adjusting a Screen Display 215

Key Points 218

Questions 218

13 ARITHMETIC:I—PROCESSING BINARY DATA 220

Introduction 220

Processing Unsigned and Signed Data 221

Addition and Subtraction 222

Extending Values in a Register 224

Performing Arithmetic on Doubleword Values 225

Multiplication 227

Performing Doubleword Multiplication 231

Special Multiplication Instructions 234

Multiplication by Shifting 235

Division 235

Division by Shifting 239

Reversing the Sign 240

The Numeric Data Processor 240

Key Points 242

Questions 243

14 ARITHMETIC:Ⅱ—PROCESSING ASCII AND BCD DATA 244

Introduction 244

Data in Decimal Format 245

Processing ASCII Data 246

Processing Unpacked BCD Data 249

Processing Packed BCD Data 251

Converting ASCII Data to Binary Format 253

Converting Binary Data to ASCII Format 255

Shifting and Rounding a Product 257

Program:Converting AsCu Data 257

Key Points 263

Questions 264

15 DEFINING AND PROCESSING TABLES 265

Introduction 265

Defining Tables 265

Direct Addressing of Table Entries 267

Searching a Table 271

The XLAT (Translate) Instruction 277

Program:Displaying Hex and ASCII Characters 278

Sorting Table Entries 280

Linked Lists 281

The TYPE,LENGTH,and SIZE Operators 286

Key Points 286

Questions 287

Part E Advanced Input/Output 289

16 DISK STORAGE Ⅰ ORGANIZATION 289

Introduction 289

Disk Characteristics 289

The Disk System Area and Data Area 292

The Boot Record 294

The Directory 294

The File Allocation Table 296

Exercise:Examining the FAT 299

Processing Files on Disk 302

Key Points 302

Questions 302

17 DISK STORAGE Ⅱ WRITING AND READING FILES 304

Introduction 304

ASCIIZ Strings 305

File Handles 305

Error Return Codes 305

File Pointers 306

Using File Handles to Create Disk Files 306

Using File Handles to Read Disk Files 311

Using File Handles for Random Processing 313

Program:Processing an AScu File 320

Absolute Disk I/O 324

Disk Services Using File Control Blocks 325

Key Points 330

Questions 330

18 DISK STORAGE Ⅲ.INT 21H FUNCTIONS FOR SUPPORTING DISKS AND FILES 332

Introduction 332

Operations Handling Disk Drives 333

Program:Reading Data from Sectors 342

Operations Handling the Directory and the FAT 345

Program:Displaying the Directory 346

Operations Handling Disk Files 348

Program:Selectively Deleting Files 353

Key Points 356

Questions 356

19 DISK STORAGE Ⅳ: INT 13H DISK FUNCTIONS 357

Introduction 357

BIOS Status Byte 358

Basic INT I3H Disk Operations 358

Program:Using INT I3H to Read Sectors 360

Other INT I3H Disk Operations 363

Key Points 368

Questions 368

20 FACILITIES FOR PRINTING 369

Introduction 369

Common Printer Control Characters 370

INT 2IH Function 40H:Print Characters 370

Program:Printing With Page Overflow and Headings 371

Program:Printing ASCII Files and Handling Tabs 374

INT 2IH Function O5H:Print Character 378

Special Printer Control Characters 379

INT I7H Functions for Printing 380

Key Points 381

Questions 381

21 OTHER INPUT/OUTPUT FACILITIES 383

Introduction 383

Mouse Features 383

Mouse Functions 384

Common INT 33H Operations 385

Program:Using the Mouse 391

Ports 394

String Input/Output 395

Generating Sound 397

Key Points 397

Questions 398

Part F Advanced Programming 400

22 DEFINING AND USING MACROS 400

Introduction 400

Two Simple Macro Definitions 401

Using Parameters in Macros 402

Macro Comments 403

Using a Macro Within a Macro Definition 405

The LOCAL Directive 407

Including Macros from a Library 407

Concatenation 410

Repetition Directives 410

Conditional Directives 412

Key Points 416

Questions 417

23 LINKING TO SUBPROGRAMS 419

Introduction 419

The SEGMENT Directive 420

Intrasegment Calls 421

Intersegment Calls 422

The EXTRN and PUBLIC Attributes 423

Using EXTRN and PUBLIC for an Entry Point 425

Defining the Code Segment as PUBLIC 427

Using Simplified Segment Directives 429

Defining Common Data as PUBLIC 430

Defining Data in Both Programs 431

Passing Parameters to a Subprogram 433

Linking Pascal with an Assembly Language Program 436

Linking C with an Assembly Language Program 440

Key Points 442

Questions 444

24 MEMORY MANAGEMENT 445

Introduction 445

The Main DOS Programs 445

The High-Memory Area 446

The Program Segment Prefix 447

Memory Blocks 452

Memory Allocation Strategy 455

The Program Loader 456

Allocating and Freeing Memory 462

Loading or Executing a Program Function 463

Program Overlays 464

Resident Programs 470

Key Points 475

Questions 476

Part G Reference Chapters 478

25 BIOS DATA AREAS AND PROGRAM INTERRUPTS 478

Introduction 478

The Boot Process 478

The BIOS Data Area 479

Interrupt Services 482

BIOS Interrupts 483

BIOS:DOS Interface 487

DOS Interrupts 487

INT 2IH Services 488

Key Points 494

Questions 495

26 OPERATORS AND DIRECTIVES 497

Introduction 497

Type Specifiers 497

Operators 498

Directives 504

27 THE PC INSTRUCTION SET 525

Introduction 525

Register Notation 526

The Addressing Mode Byte 526

Two-Byte Instructions 527

Three-Byte Instructions 528

Four-Byte Instructions 528

Instruction Set 529

APPENDIXES 557

A Conversion Between Hexadecimal and Decimal Numbers 557

B ASCII Character Codes 560

C Reserved Words 562

D Assembler and Link Options 564

E The DEBUG Program 572

F Keyboard Scan Codes and ASCII Codes 579

ANSWERS TO SELECTED QUESTIONS 583

INDEX 595