Jeff Duntemann. Assembly Language. Programming with Linux. Step by Step THIRD EDITION

Similar documents
Join the p2p.wrox.com. Wrox Programmer to Programmer. Beginning. Python. Using Python 2.6 and Python 3.1. James Payne

TELLING STORIES A SHORT PATH TO WRITING BETTER SOFTWARE REQUIREMENTS

New. On Smith s A Tree Grows in Brooklyn. Over 300 Titles Available and 100 Million Sold. 24-hour-a-day downloads at cliffsnotes.

ebay For Seniors Learn to: Marsha Collier Making Everything Easier! Get your own ebay account for buying and selling

Excel Formulas and Functions FOR. DUMmIES. by Ken Bluttman and Peter G. Aitken

Visual Basic 2008 FOR. DUMmIES. by Bill Sempf

Tumblr FOR PORTABLE EDITION

Digital Filmmaking For Kids

Visual Guide to Elliott Wave Trading

Do s and Don ts to Protect Your Financial Life BEN STEIN

HYPNOTIC WRITING How to Seduce and Persuade Customers with Only Your Words JOE VITALE John Wiley & Sons, Inc.

my lie MEREDITH MARAN A True Story of False Memory Best-selling author of What It s Like to Live Now and Class Dismissed

ANN HANDLEY AND C.C. CHAPMAN

Math For Real Life FOR

Jeremy Baras

Declutter Your Life How Outer Order Leads to Inner Calm

SURVEYING (VOLUME II)

3DTV CONTENT CAPTURE, ENCODING AND TRANSMISSION

JOSHI s Process Equipment Design

Arabic. DUMmIES. by Amine Bouchentouf FOR

11 BOOKS. Starting an Online Business. Making Everything Easier! 2nd Edition. Inside your Google AdWords gift card worth $25

Learn to: Paulina Christensen, PhD Anne Fox Wendy Foster. 2nd Edition

Home Staging. DUMmIES

SAMPLE LESSON BUY EBOOK NOW. Learn to Read Music! Buy Ebook NOW 1

Human Rights Violation in Turkey

SharePoint 2010 BOOKS. Microsoft. Emer McKenna Kevin Laahs Veli-Matti Vanamo. Making Everything Easier!

Radiology for Undergraduate Finals and Foundation Years

Environmental Impact of Fertilizer on Soil and Water

ELECTRIC POWER SYSTEMS

THE ORGANIZATIONAL ALIGNMENT HANDBOOK. A Catalyst for Performance Acceleration

Enjoy Writing. your Science Thesis or Dissertation!

Beet-Sugar Handbook ffirs.indd i ffirs.indd i 10/12/2006 3:01:08 PM 10/12/2006 3:01:08 PM

The Discourse of Peer Review

3DTV CONTENT CAPTURE, ENCODING AND TRANSMISSION

Little Book Big Profits Series

Ableton Live 8 and Suite 8

Teaching and the Internet: The Application of Web Apps, Networking, and Online Tech for Chemistry Education

KIDS INVENTING! A Handbook for Young Inventors SUSAN CASEY

Amber, Resinite, and Fossil Resins

_FM 7/22/09 10:10 AM Page 1 COLLABORATING. with SharePoint. Carey Cole

ISBN-13. Everything you need to know about the ISBN-13 transition. The Book Industry Study Group, Inc. Brought to you by.

Epoxy Resin Chemistry II

Being Agile. Your Roadmap to Successful Adoption of Agile. Mario E. Moreira

The Power Filmmaking Kit

The Contemporary Novel and the City

Clean Code.

Women, Authorship and Literary Culture,

Luminescence Applications

Early Power and Transport

Efficient Organic Light-Emitting Diodes (OLEDs)

Move & Store Cart CONTENTS. Assembly Instructions

Modular Narratives in Contemporary Cinema

SAP Edge Services Edge Services Overview Guide Version 1711

SIR WALTER RALEGH AND HIS READERS IN THE SEVENTEENTH CENTURY

Negotiation Exercises for Journal Article Publishing Contracts and Scholarly Monograph Publishing Contracts

What s New in Visual FoxPro 7.0

Narratives of the Revolutionary and Napoleonic Wars

See Education Licence B: Statutory Text and Artistic Licence for further information

Racial Profiling and the NYPD

SpringerBriefs in Electrical and Computer Engineering

Defining Literary Criticism

Conrad s Eastern Vision

The. Craft of. Editing

User s manual. Digitales TV module for NAVIGON English (United Kingdom)

Flue Gas Desulfurization

Jane Dowson. Carol Ann Duffy. Poet for Our Times

Reasonably Simple Economics

Romanticism, Medicine and the Natural Supernatural

Mourning, Modernism, Postmodernism

Buy The Complete Version of This Book at Booklocker.com:

Practical Recording Techniques. Fifth Edition

Xpedition Layout for Package Design. Student Workbook

Descartes Philosophical Revolution: A Reassessment

The Grotesque in Contemporary Anglophone Drama

Applied Tribology. M. M. Khonsari and E. R. Booser

Existentialism and Romantic Love

Well, my name is Iggy, said the second toe. And my name is Ziggy, said the fourth toe.

DOI: / William Corder and the Red Barn Murder

New Encoding Technique to Reform Erasure Code Data Overwrite Xiaodong Liu & Qihua Dai Intel Corporation

Heritage, Nostalgia and Modern British Theatre

Protecting Chips Against Hold Time Violations Due to Variability

Problem Books in Mathematics

The Elegies of Ted Hughes

Mathematics, Computer Science and Logic - A Never Ending Story

Introduction to the Sociology of Development

Paul M. Gauthier. Lectures on Several Complex

Calculating the Human

Intellectuals and Politics in Post-War France

Family Plays. Excerpt Terms & Conditions. This excerpt is available to assist you in the play selection process.

Appraising Research: Evaluation in Academic Writing

The Chemistry of Solid Wood

SPRINGER-SCIENCE+BUSINESS MEDIA, B.V.

MOB501. SAP Omnichannel Banking 8.3 SP01 PL03 Development COURSE OUTLINE. Course Version: 03 Course Duration: 4 Day(s)

CHILDREN S ESL CURRICULUM: LEARNING ENGLISH WITH LAUGHTER

TOLKIEN: A CRITICAL ASSESSMENT

The Tudors. Learn about: Tudor life and times and how they shaped the Britain of today. David Loades. Mei Trow. Making Everything Easier!

The Films of Martin Scorsese,

Femininity, Time and Feminist Art

Kamai Hybrid TV Media Player

Literature and Politics in the 1620s

Transcription:

Jeff Duntemann Assembly Language Step by Step Programming with Linux THIRD EDITION

Assembly Language Step-by-Step

Assembly Language Step-by-Step Programming with Linux Third Edition Jeff Duntemann Wiley Publishing, Inc.

Assembly Language Step-by-Step Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright 2009 by Jeff Duntemann Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-49702-9 Manufactured in the United States of America 10987654321 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Control Number: 2009933745 Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Linux is a registered trademark of Linus Torvalds. All other trademarks are the property of their respective owners. Wiley Publishing, Inc. is not associated with any product or vendor mentioned in this book.

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 Jeff Duntemann is a writer, editor, lecturer, and publishing industry analyst. In his thirty years in the technology industry he has been a computer programmer and systems analyst for Xerox Corporation, a technical journal editor for Ziff-Davis Publications, and Editorial Director for Coriolis Group Books and later Paraglyph Press. He is currently a technical publishing consultant and also owns Copperwood Press, a POD imprint hosted on lulu.com. Jeff lives with his wife Carol in Colorado Springs, Colorado. vii

Credits Executive Editor Carol Long Project Editor Brian Herrmann Production Editor Rebecca Anderson Copy Editor Luann Rouff Editorial Director Robyn B. Siesky Editorial Manager Mary Beth Wakefield Production Manager Tim Tate Vice President and Executive Group Publisher Richard Swadley Vice President and Executive Publisher Barry Pruett Associate Publisher Jim Minatel Project Coordinator, Cover Lynsey Stanford Proofreader Dr. Nate Pritts, Word One Indexer J&J Indexing Cover Image Jupiter Images/Corbis/ Lawrence Manning ix

Acknowledgments First of all, thanks are due to Carol Long and Brian Herrmann at Wiley, for allowing this book another shot, and then making sure it happened, on a much more aggressive schedule than last time. As for all three previous editions, I owe Michael Abrash a debt of gratitude for constant sane advice on many things, especially the arcane differences between modern Intel microarchitectures. Although they might not realize it, Randy Hyde, Frank Kotler, Beth, and all the rest of the gang on alt.lang.asm were very helpful in several ways, not least of which was hearing and answering requests from assembly language newcomers, thus helping me decide what must be covered in a book like this and what need not. Finally, and as always, a toast to Carol for the support and sacramental friendship that has enlivened me now for 40 years, and enabled me to take on projects like this and see them through to the end. xi

Contents at a Glance Introduction: Why Would You Want to Do That? xxvii Chapter 1 Another Pleasant Valley Saturday 1 Chapter 2 Alien Bases 15 Chapter 3 Lifting the Hood 45 Chapter 4 Location, Location, Location 77 Chapter 5 The Right to Assemble 109 Chapter 6 A Place to Stand, with Access to Tools 155 Chapter 7 Following Your Instructions 201 Chapter 8 Our Object All Sublime 237 Chapter 9 Bits, Flags, Branches, and Tables 279 Chapter 10 Dividing and Conquering 327 Chapter 11 Strings and Things 393 Chapter 12 Heading Out to C 439 Conclusion: Not the End, But Only the Beginning 503 Appendix A Partial x86 Instruction Set Reference 507 Appendix B Character Set Charts 583 Index 587 xiii