IBM PC汇编语言程序设计

IBM PC汇编语言程序设计
作 者: 阿贝尔
出版社: 清华大学出版社
丛编项: 大学计算机教育国外著名教材系列
版权说明: 本书为公共版权或经版权方授权,请支持正版图书
标 签: 汇编语言 程序设计 高等学校 教材
ISBN 出版时间 包装 开本 页数 字数
未知 暂无 暂无 未知 0 暂无

作者简介

暂缺《IBM PC汇编语言程序设计》作者简介

内容简介

《大学计算机教育国外著名教材系列:IBM PC汇编语言程序设计(第5版)(影印版)》主要介绍用汇编语言进行程序设计,先从硬件和软件着手,然后介绍编程所需的各种指令,并给出丰富的范例。全书分为七大部分:PC机硬件、软件基础,汇编语言基础,屏幕与键盘操作,数据操作,高级输入/输出,特别主题,以及关于BI0S数据区、中断与端口、运算符与指令、PC指令系统等的参考资料。《大学计算机教育国外著名教材系列:IBM PC汇编语言程序设计(第5版)(影印版)》既可作为计算机及相关专业汇编语言课程的教材,也可作为开发人员的参考用书。要掌握《大学计算机教育国外著名教材系列:IBM PC汇编语言程序设计(第5版)(影印版)》内容,不仅要认真阅读《大学计算机教育国外著名教材系列:IBM PC汇编语言程序设计(第5版)(影印版)》的每个章节,还应使用《大学计算机教育国外著名教材系列:IBM PC汇编语言程序设计(第5版)(影印版)》提供的范例并尝试运行这些范例,并认真完成每章后面的练习。

图书目录

NDEX 533CONTENTS

PREr^cE - yi

xI

cart A FundamentalS of PC Hardware and SOfware 1

l BASIC FE^rURES OF PC HARDw^RE 1

Introduction 1

Bits and BVtes 1

ytes 1

ac o: Number SI

foe Binary Number System 3

j I yotem 3

Hexadecimal Representation 6

presentation 6

ASCll Code 7

PC ComDonents 8

ponents 8

Internal Memory 10

j 10

Rocrmporits and AddressinZ 1,

begments and Addressing 12

.Inents and Addressing 12

Registers 13

.lsters 13

Hardware interrupts 18

KeV Points ] 9

y Points 19

Review Questions and Exercises 19

2 INSTRUCTION ADDREssiNG AND EXECUTION 22

Introduction 22

Features of an Operating System 22

perating System 22

. Contents

IV

al ATal O O-,7

she BIOS Boot Process 23

Ic q1TRr DWrn T l,4

she System Program Loader 24

totem Program Loader 24

ac aam l,<

foe Stack 25

Instruction Execution and Addressing 27

Instruction Operands 29

Protected Mode 29

Key Points 30

J

Review Questions and Exercises 30

3 EXAMINING COMPUTER MEMORY AND EXECUTING INSTRUCTIONS 32

Introduction 32

Using the DEBUG Program 32

Viewing Memory Locations 34

Machine Language Example i: Using Immediate Data 36

Machine Language Example II: Using Defined Data 40

An Assembly Language Program 44

Using the INT Instruction 45

Using the PTR Operator 47

KeV Points 48

J Points 48

Review Questions and Exercises 49

Part B FundamentalS of ASSembly Language 51

4 REQUIREMENTS FOR CODING IN ASSEMBle LANGU^oE 51

Introduction 51

Assembly Language Features 52

Conventional Segment Directives 58

Qimrilifipod aeon

simplified Segment Directives 62

Initializing for Protected Mode 64

Defining Types of Data 65

Equate Directives 70

Key Points 72

y Points 72

Review Questions and Exercises 73

5 ASSEMBLING, LINKING, AND EXECUTING PROGRAMS 74

Introduction 74

Preparing a Program for Assembling and Execution 74

m acal hi R 1

fwo-Pass Assembler sl

Linking an Object Program sl

Executing a Program 83

ac

foe Cross-Reference Listing 84

Error Diagnostics 84

ale hi T.

foe Assembler Location Counter 85

Writing .COM Programs 86

Contents v

Key Points 89

y Points 89

Review Questions and Exercises 90

6 SYMBOLIC INSTRUCTIONS AND ADDRESSING 92

Introduction 92

ac q- 1 1. T.

foe SVmbolic instruction Set--An Overview 92

Jlnbolic instruction Set--An Overview 92

Data Transfer instructions 95

Basic Arithmetic instructions 97

Repetitive Move Operations 98

'.

ac TNT Instfuction 100

foe INT Instruction 100

Addressing Modes 100

e,dodes 100

ac q

foe Segment Override Prefix 104

.Inent Override Prefix 104

Near and Far Addresses 105

Aligning Data Addresses 105

.mug Data Addresses 105

Key Points ] 06

j POints 106

Review Questions and Exercises 106

7 PROGRAM LOGIC AND CONTROL 109

Introduction 109

Rhoft, Near, and Far Addresses 1 10

short, Near, and Far Addresses 1 10

al T' -n r.

foe JMP Instruction 1 1 1

ac T aam T.

foe LOOP Instruction 1 13

ac al ac o.

foe Flags Register 114

ba Register 114

ac

foe CMP Instruction 1 15

Conditional Jump instructions 116

I

Calling Procedures 119

b Procedures 1 19

ac aam

foe Effect of Program Execution on the Stack 121

brain Execution on the Stack 121

Boolean Operations 125

shifting aide 1 aam

shifting Bits 128

b Bits 128

Rotating Bits 131

o Bits 131

Organizing a Program 133

.antiing a Program 133

Key Points 134

j I olnts 134

Review Questions and Exercises 135

Part C Video and K6yboard Operations 137

8 INTRODUCTION TO VIDEO AND KEYBo^RD PROCESSING 137

Introduction 137

q Features 138

screen Features 138

qrrttiria the Cursor 138

betting the Cursor 138

o Lhe Cursor 138

Clearing the Screen 139

g the Screen 139

INT ZIH Function 09H for Screen DisplaV 139

play 139

INT 21H Function OAH for KeVboard InDut 141

J Doard input 141

INT 21H Function 02H for Screen Display 147

- aam riforitc

yi contents

File Handles 148

INT ZIH Function 40H for Screen Display 148

INT ZIH Function 3FH for Keyboard input 149

KeV Points 151

j I Olnts 151

Review Questions and Exercises 151

- -

9 VIDEO SySTEMS 153

Introduction 153

Components of a Video System 154

Video Modes 156

Attributes 156

BIOS INT IOH Operations 158

Using Graphics Mode 175

Direct Video Display 179

ASCll Characters for Boxes and Menus 182

Key Points 183

J Points 183

Review Questions and Exercises 184

1 0 KEYBo^RD OPER^rlONS 1 86

Introduction 186

BIOS KeVboard Data Areas 187

J board Data Areas 187

INT 21H for Keyboard input 188

INT 16H for Keyboard input 189

Extended Function Keys and Scan Codes 192

BIOS INT 09H and the Keyboard Buffer 197

Key Points 199

j I olnts 199

Review Questions and Exercises 201

Part D Data Manipulation 203

1 1 PROCESSING STRING D^r^ 203

Introduction 203

Features of String Operations 204

MOVSf Move String instruction 205

LODSt Load String instruction 207

ITOS: Store String instruction 207

o fOS: Store String instruction 207

Program f Using LODS and STOS to Edit Data 208

CMPSf Compare String instruction 209

ICAS. Scan StrinZ Instruction 213

.CAS. Scan String instruction 213

Alternative Coding for String instructions 214

Replicating a Pattern 215

KeV Points 215

J Points 215

Review Questions and Exercises 216

Contents vii

1 2 ARITHMETIC I' PROCESSING BINARY D^r^ 218

Introduction 218

Processing Unsigned and Signed Binary Data 218

b .lied and Signed Binary Data 218

Addition and Subtraction of Binary Data 220

j Data 220

Multiplying Binary Data 225

.

Dividing BinarV Data 232

b Binary Data 232

al Numeric Data Processor 237

foe Numeric Data Processor 237

KeV Points 239

J Points 239

Review Questions and Exercises 239

13 ARITHMETIC 114 PROCESSING ASCll AND BCD DATA 241

Introduction 241

Data in Decimal Format 242

Processing ASCll Data 242

b ASCll Data 242

Processing Packed BCD Data 247

o Packed BCD Data 247

Converting ASCll Data to Binary Format 250

o ASCll Data to Binary Format 250

Converting Binary Data to ASCll Format 251

o Binary Data to ASCll Format 251

qhiftiricr orid Roundinl

ofliftinR and Rounding a Product 252

o and Rounding a Product 252

Key Points 257

J

Review Questions and Exercises 258

14 DEFINING AND PROCESSING TABLES 259

Introduction 259

Defining Tables 259

o fables 259

Direct Addressing of Table Entries 261

Roqrnhiricr q Table.

searching a Table 264

b a fable 264

ac arT 'm /m 1'

foe XLAT (Translate) Instruction 268

Q rartiri a Table aam

borting Table Entries 271

o table Entries 271

Address Tables 274

Ti-, ri.. 1 ^ laal

fwo-Dimensional Arrays 275

y3 275

Key Points 278

J I olnts 278

Review Questions and Exercises 278

PART E Advanced Input,Output 281

1 5 FACILITIES FOR USING THE MOUSE 281

Introduction 281

Basic Mouse Operations 283

Program: Displaying the Mouse Location 284

More Advanced Mouse Operations 287

perations 287

Program: Using the Mouse with a Menu 290

KeV Points 293

y Points 293

Review Questions and Exercises 294

... nrintents

viII contents

16 DISK STOR^oE I' ORGANIZ^rlON 295

Introduction 295

Characteristics of a Disk Storage Device 295

ac fbi FI q-,

foe Disk System Area and Data Area 299

y alem Area and Data Area 299

al n n 1 7fin

foe Boot Record 300

ac acid

foe DirectorV 301

J

ac ail 1 11. acal in

she File Allocation Table 302

Processing Files on Disk 307

Key Points 308

y Points 308

Review Questions and Exercises 308

1 7 DISK STOR^oE II: WRITING AND READING FILES 310

Introduction 310

ASCllZ Strings 310

File Handles 311

Error Return Codes 31 1

File Pointers 311

Creating Disk Files 312

Reading Disk Files 314

Random Processing 318

KeV Points 327

j I olnts 327

Review Questions and Exercises 328

1 8 DISK STOR^oE Ill. INT 21 H FUNCTIONS FOR SUPPORTING DISKS AND FILES 330

Introduction 330

Operations Handling Disk Drives 331

Operations Handling the Directory and the FAT 341

Operations Handling Disk Files 343

KeV Points 349

J Points 349

Review Questions and Exercises 352

19 DISK STOR^oE IVy INT 13H DISK FUNCTIONS 353

Introduction 353

BIOS Status Byte 354

Basic INT 13H Disk Operations 354

Other INT 13H Disk Operations 358

Key Points 362

j I olnts 362

Review Questions and Exercises 363

20 FACILITIES FOR PRINTING 364

Introduction 364

Common Printer Control Characters 364

INT ZIH Function 40H: Print Characters 365

COntents ix

IX

qripni of Priritrvr Conl

special Printer Control Characters 369

BIOS INT 17H Functions for Printing 373

Key Points 374

j I olnts 374

Review Questions and Exercises 375

Part F Special ropies 377

ZI DEFINING AND USING MACROS 377

Introduction 377

qirnrile Macro Definitions 378

dimple Macro Definitions 378

Using Parameters in Macros 379

b Parameters in Macros 379

Using Comments in Macros 380

6

Nested Macros 382

Macro Directives 383

KeV Points 391

j I Olnts 391

Review Questions and Exercises 392

22 LINKING TO SUBPROGR^MS 393

Introduction 393

ac gb

foe SEGMENT Directive 394

Intrasegment Calls 395

Intersegment Calls 396

.Inent Calls 396

The EXTRN and PUBLIC Attributes 397

Using EXTRN and PUBLIC for an EntrV Point 398

b ac FRN and PUBLIC for an Entry Point 398

Defining the Code Segment as PUBLIC 400

b the Code Segment as PUBLIC 400

UsinZ SimDlified SeZment Directives 402

o simplified Segment Directives 402

Passing Parameters to a Subprogram 404

b Parameters to a Subprogram 404

The ENTER and LEAVE Instructions 406

Linking a C/C++ Program with an Assembly Language Program 408

b a C/C++ Program with an Assembly Language Program 408

Key Points 412

J Points 412

Review Questions and Exercises 412

23 PROGRAM Lo^DING AND OVERL^vS 414

Introduction 414

The Program Segment Prefix 414

The HiZh-Memory Area 418

.if-Memory Area 418

Memory Allocation Strategy 418

J allocation Strategy 418

The Program Loader 419

Allocating and Freeing Memory 424

b and Freeing Memory 424

Loading or Executing a Program Function 425

b o a Program Function 425

Program OverlaVs 428

cram Overlays 428

Resident Programs 432

Key Points 435

y Points 435

Review Questions and Exercises 436

x Contents

Part G Reference Chapters 437

24 BIOS D^r^ AREAS, INTERRUPts, AND PORes 437

Introduction 437

ac P

Yhe Boot Process 437

ac pTriq no+o 4 ~ 4

foe BIOS Data Area 438

Interrupt Services 442

BIOS Interrupts 443

pts 443

INT 21H Services 446

Ports 451

qttiriq Tnrilltloutl

oning input/OutDUt 453

o Input/Output 453

Generating Sound 454

KeV Points 455

J Points 455

Review Questions and Exercises 456

25 OPER^rORS AND DIRECTIVES 458

Introduction 458

yi, aam. G 4 F R

YVpe Specifiers 458

ape Specifiers 458

Operators 459

Directives 463

26 THE PC INSTRUCTION SET 479

Introduction 479

Register Notation 480

ac I I l-. A' I n1Tt 4

foe Addressing Mode Byte 480

o .bode Byte 480

ac Tab of~' 1.

foe instruction Set 483

APPENDICES

A CONVERSION BEtwEEN HEXADECIMAL AND DECIMAL NUMBERS 508

B ASCll CHAR^cTER CODES sl 1

C THE DEBUG PROGRAM 513

D RESERVED WORDS 520

E ASSEMBLING AND LINKING PROGRAMS 522

F KEYBo^RD Sc^N CODES AND ASCll CODES 528