The 80386 Book [Paperback ed.]
 1556151381, 9781556151385

Table of contents :
Contents
Introduction
1 Evolution of the 80386 Architecture
2 The 80386 Architecture
3 Memory Architecture Segmentation
4 The 80386 Instruction Set
5 The 80386 Protection Mechanism
6 Memory Architecture Paging
7 Three in One
8 The 80386/80387 Instruction Set Reference
Appendix A Powers of Two
Appendix B ASCII Character Set
Appendix C Opcode Table
Appendix D Instruction Format and Timing
Appendix E Instruction Disassembly Table
Appendix F 8086-Family Processor Differences

Index

Citation preview

a o S a

B O O F T

Aavmbly

Lulguge

htgmmmer's

Gtitfufor the

o

[y tnss llnl$ol

80386

/

T H E . A O S A 6 . B O O K

ly Inss Rllnlsnn

7

I PUBIISI.IED BY A Division of MicrGoft Co.poration 16011NE 36dr \vay, Box 97017,Redmond,washinBton 98073-9717 copyright @ 1988by RossP Nelson All righls reserved. No pan of the contents of this booli oay be reprod!.ed or transnifted in any lorm or by any meanswithom the writren pdnission of the publishei Library oi CongresscaraloSing in Publication Ddta Thc 30336book assenbly languageprogrammc/s guide fd the 80386/

2 Assembletl,nguage 1. lnrcl 81386(Microproce$or)-l,rqra'n'ning (Comprtcrprogran l{ntuage) L Titlc l98a 88-21106 QA768.I2928N45 CIP 005265-dd9 ISIIN1-t56lt-138-1 Prinrcdlnd hou.d in dlc UnitcdSrdresoi Amc.ica, 1 2 3 4 5 6 1 8 9 M r , M r 3, 2 r 0 9 8 Diskibutcdto thc b@k lr{de in Lhcunncd StatcsbI Harper& Row PublkhlneCompary,Ltd Distributcdto thc book ftadc in C?nadaDyCcneral to thc l$ok Mdc olt6idc thc UniredstaresandCanadaby Pengui.tsookrLtd. Di$rribtrrcd lcnguin looks Ltd , Hlmondsworth, Mlddlcsex,Engl,nd Pcqtui. BooksAustraliahd., Ringwood,vi.tdi!, Austiaxa PeqtuinDooksNZ. Ltd , 182-190'q/air!ultodd,Auckland10,Ncwzeala.d Brnjshcdkbging in PublicarionDara avail.ble Incorporaledlnrclo is a IDM@is a tr.dehdrk oilntcrnatlon.lDusincssMxchiresCorPoration, trademarks are rcCistered registeredrradenalk oflntcl Corporation.MjcrosoltoandMS-DOS@ of Miclosoffcorpo.ation.Al I mnemonicscotyrlShtIntcl corporation1986,1987

Acqutsttlotr Edltoi: ClNdeue Mooie ProJecrB.Utor: Deb Lewy Techntcll Edttor: David Rygmir Mmusc.tpt Erlttoi Mi.heleTomiak

ToRobertanclArdell Nelson

Contents Introduction Evolution of the 80386Architecturc The 80386Architecturc

1 '13

MemoryArchitecturerSegmentation 43 4

The 80386Instruction Ser

63

5

The 80386ProtectionMechanism

93

6

MemoryArchitecrurerPaging

125

7

Three in One

135

a

The 80386/80387Instruction Set Reference

147

Appandlx A Poncrs ofTWo

381.

App€ndlxB ASCII CharacterS€t

383

Appondlx C Opcode Table

Jd)

Appondlx D Instruction Formatand Timing

397

Appondk E Insftuction DisassemblyTable

433

Appendix F 8086-FamilyProcessorDifferences

441,

Index

445

Acknowledgments A nurnber of people deserve credit for helping make this book a realiry. Some I have spoken with and worked with directly; others have worked behind the scenes,doing a wonderful job nonetheless.Y/orking with the people at Microsoft Presswas a positive experience,and I sincerely thank them all for their support and encouragement.In addition, my thanks to RayDuncan for getting the ball rolling, to Intel corporation for its cooperation, () Matt Trask for his technical review, to my covr'orkersat Answer Soft$/arefor thct support, and especi^lly to Pamfor always believingin me. This is a book about microprocessortechnology, so of courseit was written wilh the assistanceof microprocessortechnology, I completed a large Portion of the manuscriptusing a ToshibaT1000portable computer while riding ShntaClara County Transit, RossN€lson June 1988

tx

INTRODUCTION centralProis probablythe mostwidelydiscu$sed The Intcl 80386microprocessor cessingunit (CPU)chip sinccihe introductionof the 8080in the earlydaysof personal computir\g. This book lets you know whal all the slrcr.rtingis about Aft€r presenting a history of the 80i|6 microprocessorfhmily in chapter 1, erch subdiscusses a portionof the 80386designThe o€anizationof the sequentchaptcr prcscnted in Chapter2. Thc basicmemoryarchitectureis discussedin ChapCPUis ter 3. Cbapter4 introducesrhe instructionsetof b(nh tlle 80386proccssorand the operaof Prolccled-mode 80387numericcoprocessorCh4pter5 is an exPlanAtion Compatibility paging memory sysicm how extends thc tbn. Chnpter6 explains via renlmode,virtualll0ti6mode,ancllhc 80286is covcrcd wilh previousprocessors in chapter7. Finally,ChaptcrSprovidesa fullinstructionsetrclcrcnce This book focuse$cntirelyon programmiqg.l! doesnol discussthe hardwarcfea_ turesofth€ proccssorunlesstlmsefcaturesrelateto spccificinstructionslfyou are interest€din thc hardwarecharaclcristicsof the 80386,refet ta the a0i86 Data ShL\lt^nd rhe 80386H.$duarc RelbrenceManual both pubiisheclby Intel Corporation. To gel the most from this book, you shouldbe familiar with computer syste,ns.h arithmeticand machincparticular,an underslanding ofbinary anclhexadecimal processor(s) will bc hclpful programming some othef for language A large poriion of the book is devoted to the i10386'sprotected mode Alrhough you l ' t'.8rm lhc 80Jd6rr i.rmponanttuur_ d6 norneedro under.l"rJrhr.learure derstandprotected mode to grasp why systemdesignershavc made the choices rhc Os 2. wiadoss J8o.PCN'tOsJM ard I NIX rh