Duntemann Learn assembly language, A and you learn the machine s Jeff Duntemann s In this third edition of his bestselling guide to Intel x86 assembly language under Linux, Jeff e Duntemann positions assembly not as unapproachable geek arcana but as a fi rst programming m language, suitable for readers who have no previous programming experience. As the fundamental language of the CPU, assembly lays the groundwork for all other programming languages, b Assembly especially native-code C, C++, and Pascal. By mastering assembly, programmers will learn how P x86 computers operate all the way down to “the bare silicon,” at a level of detail that no other l r y approach can equal. o g L Assembly Language Step by Step, Third Edition, helps you: r a (cid:127) Review the fundamental concepts behind (cid:127) Learn the x86 instruction set by dissecting a Language computing and programming, including the numerous complete example programs m n hexadecimal and binary number bases (cid:127) Work with the wealth of free programming m g (cid:127) Understand the evolution of the Intel CPUs and utilities under Ubuntu Linux, including the Kate u i how modern x86 processors operate editor, the NASM assembler, and the GNU toolset n a Step by Step g (cid:127) Grasp the process of programming itself, from (cid:127) Master practical details of Linux programming, g editing source code through assembly, linking, including procedures, macros, the INT 80h call w and debugging gate, and calls to the standard C libraries e i t (cid:127) Comprehend x86 32-bit protected-mode h memory addressing S L i t Programming with Linux Jeff Duntemann has been writing about computing for over thirty years, and is the author of numerous books on n e ® u programming, wireless networking, and system administration. He has been a columnist in Dr. Dobb’s Journal, and has p edited well-known programming publications like PC Techniques and Visual Developer. After hours, he enjoys blogging, x astronomy, amateur radio, and writing science fi ction. ® b y S t e p THIRD EDITION THIRD EDITION $65.00 US /$78.00 CAN Visit our Web site at www.wiley.com/compbooks Software Development/General Assembly Language Step-by-Step Assembly Language Step-by-Step ® Programming with Linux Third Edition Jeff Duntemann Wiley Publishing, Inc. AssemblyLanguageStep-by-Step Publishedby WileyPublishing,Inc. 10475CrosspointBoulevard Indianapolis,IN46256 www.wiley.com Copyright©2009byJeffDuntemann PublishedbyWileyPublishing,Inc.,Indianapolis,Indiana PublishedsimultaneouslyinCanada ISBN:978-0-470-49702-9 ManufacturedintheUnitedStatesofAmerica 10987654321 Nopartofthispublicationmaybereproduced,storedinaretrievalsystemortransmittedinanyformorbyanymeans, electronic,mechanical,photocopying,recording,scanningorotherwise,exceptaspermittedunderSections107or108 ofthe1976UnitedStatesCopyrightAct,withouteitherthepriorwrittenpermissionofthePublisher,orauthorization throughpaymentoftheappropriateper-copyfeetotheCopyrightClearanceCenter,222RosewoodDrive,Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the PermissionsDepartment,JohnWiley&Sons,Inc.,111RiverStreet,Hoboken,NJ07030,(201)748-6011,fax(201)748-6008, oronlineathttp://www.wiley.com/go/permissions. LimitofLiability/DisclaimerofWarranty:Thepublisherandtheauthormakenorepresentationsorwarrantieswith respecttotheaccuracyorcompletenessofthecontentsofthisworkandspecificallydisclaimallwarranties,including withoutlimitationwarrantiesoffitnessforaparticularpurpose.Nowarrantymaybecreatedorextendedbysalesor promotionalmaterials.Theadviceandstrategiescontainedhereinmaynotbesuitableforeverysituation.Thiswork issoldwiththeunderstandingthatthepublisherisnotengagedinrenderinglegal,accounting,orotherprofessional services.Ifprofessionalassistanceisrequired,theservicesofacompetentprofessionalpersonshouldbesought.Neither thepublishernortheauthorshallbeliablefordamagesarisingherefrom.ThefactthatanorganizationorWebsiteis referredtointhisworkasacitationand/orapotentialsourceoffurtherinformationdoesnotmeanthattheauthororthe publisherendorsestheinformationtheorganizationorWebsitemayprovideorrecommendationsitmaymake.Further, readersshouldbeawarethatInternetWebsiteslistedinthisworkmayhavechangedordisappearedbetweenwhenthis workwaswrittenandwhenitisread. ForgeneralinformationonourotherproductsandservicespleasecontactourCustomerCareDepartmentwithinthe UnitedStatesat(877)762-2974,outsidetheUnitedStatesat(317)572-3993orfax(317)572-4002. Wileyalsopublishesitsbooksinavarietyofelectronicformats.Somecontentthatappearsinprintmaynotbeavailable inelectronicbooks. LibraryofCongressControlNumber:2009933745 Trademarks:WileyandtheWileylogoaretrademarksorregisteredtrademarksofJohnWiley&Sons,Inc.and/orits affiliates,intheUnitedStatesandothercountries,andmaynotbeusedwithoutwrittenpermission.Linuxisaregistered trademarkofLinusTorvalds.Allothertrademarksarethepropertyoftheirrespectiveowners.WileyPublishing,Inc.is notassociatedwithanyproductorvendormentionedinthisbook. To the eternal memory of Kathleen M. Duntemann, Godmother 1920–1999 who gave me books when all I could do was put teeth marks on them. There are no words for how much I owe you! About the Author JeffDuntemannisawriter,editor,lecturer,andpublishingindustryanalyst.In histhirtyyearsinthetechnologyindustryhehasbeenacomputerprogrammer and systems analyst for Xerox Corporation, a technical journal editor for Ziff-Davis Publications, and Editorial Director for Coriolis Group Books and laterParaglyphPress.Heiscurrentlyatechnicalpublishingconsultantandalso owns Copperwood Press, a POD imprint hosted on lulu.com. Jeff lives with hiswifeCarolinColoradoSprings,Colorado. vii