- •Table of Contents
- •Foreword
- •Do Not Pass GO
- •Counting in Martian
- •Octal: How the Grinch Stole Eight and Nine
- •Hexadecimal: Solving the Digit Shortage
- •From Hex to Decimal and from Decimal to Hex
- •Arithmetic in Hex
- •Binary
- •Hexadecimal as Shorthand for Binary
- •Switches, Transistors, and Memory
- •The Shop Foreman and the Assembly Line
- •The Box That Follows a Plan
- •DOS and DOS files
- •Compilers and Assemblers
- •The Assembly Language Development Process
- •DEBUG and How to Use It
- •Chapter 5: NASM-IDE: A Place to Stand Give me a lever long enough, and a place to stand, and I will move the Earth.
- •NASM-IDE's Place to Stand
- •Using NASM-IDE's Tools
- •NASM-IDE's Editor in Detail
- •Other NASM-IDE Features
- •The Nature of Segments
- •16-Bit and 32-Bit Registers
- •The Three Major Assembly Programming Models
- •Reading and Changing Registers with DEBUG
- •Assembling and Executing Machine Instructions with DEBUG
- •Machine Instructions and Their Operands
- •Reading and Using an Assembly Language Reference
- •Rally Round the Flags, Boys!
- •Using Type Specifiers
- •The Bones of an Assembly Language Program
- •Assembling and Running EAT.ASM
- •One Program, Three Segments
- •Last In, First Out via the Stack
- •Using DOS Services through INT
- •Boxes within Boxes
- •Using BIOS Services
- •Building External Libraries of Procedures
- •Creating and Using Macros
- •Bits Is Bits (and Bytes Is Bits)
- •Shifting Bits
- •Flags, Tests, and Branches
- •Assembly Odds 'n Ends
- •The Notion of an Assembly Language String
- •REP STOSW, the Software Machine Gun
- •The Semiautomatic Weapon: STOSW without REP
- •Storing Data to Discontinuous Strings
- •Chapter 12: The Programmer's View of Linux Tools and Skills to Help You Write Assembly Code under a True 32-Bit OS
- •Prerequisites-Yukkh!
- •NASM for Linux
- •What's GNU?
- •The make Utility and Dependencies
- •Using the GNU Debugger
- •Your Work Strategy
- •Genuflecting to the C Culture
- •A Framework to Build On
- •The Perks of Protected Mode
- •Characters Out
- •Characters In
- •Be a Time Lord
- •Generating Random Numbers
- •Accessing Command-Line Arguments
- •Simple File I/O
- •Conclusion: Not the End, But Only the Beginning
- •Where to Now?
- •Stepping off Square One
- •Notes on the Instruction Set Reference
- •AAA Adjust AL after BCD Addition
- •ADC Arithmetic Addition with Carry
- •ADD Arithmetic Addition
- •AND Logical AND
- •BT Bit Test (386+)
- •CALL Call Procedure
- •CLC Clear Carry Flag (CF)
- •CLD Clear Direction Flag (DF)
- •CMP Arithmetic Comparison
- •DEC Decrement Operand
- •IMUL Signed Integer Multiplication
- •INC Increment Operand
- •INT Software Interrupt
- •IRET Return from Interrupt
- •J? Jump on Condition
- •JMP Unconditional Jump
- •LEA Load Effective Address
- •MOV Move (Copy) Right Operand into Left Operand
- •NOP No Operation
- •NOT Logical NOT (One's Complement)
- •OR Logical OR
- •POP Pop Top of Stack into Operand
- •POPA Pop All 16-Bit Registers (286+)
- •POPF Pop Top of Stack into Flags
- •POPFD Pop Top of Stack into EFlags (386+)
- •PUSH Push Operand onto Top of Stack
- •PUSHA Push All 16-Bit GP Registers (286+)
- •PUSHAD Push All 32-Bit GP Registers (386+)
- •PUSHF Push 16-Bit Flags onto Stack
- •PUSHFD Push 32-Bit EFlags onto Stack (386+)
- •RET Return from Procedure
- •ROL Rotate Left
- •ROR Rotate Right
- •SBB Arithmetic Subtraction with Borrow
- •SHL Shift Left
- •SHR Shift Right
- •STC Set Carry Flag (CF)
- •STD Set Direction Flag (DF)
- •STOS Store String
- •SUB Arithmetic Subtraction
- •XCHG Exchange Operands
- •XOR Exclusive Or
- •Appendix C: Web URLs for Assembly Programmers
- •Appendix D: Segment Register Assumptions
- •Appendix E: What's on the CD-ROM?
- •Index
- •List of Figures
- •List of Tables
Assembly Language Step-by-Step: Programming with
DOS and Linux, Second Edition
by Jeff Duntemann |
ISBN:0471375233 |
John Wiley & Sons © 2000 (613 pages) |
|
A “Lost World” journey into 16-bit assembler programming concepts and techniques.
<?xml version="1.0" encoding="ISO-8859-1"?>
Table of Contents
Assembly Language Step-by-Step—Programming with DOS and Linux, Second
Edition
Foreword
Introduction - "Why Would You Want to Do That?"
Chapter 1 - Another Pleasant Valley Saturday Understanding What Computers Really Do
Chapter 2 - Alien Bases Getting Your Arms around Binary and Hexadecimal Chapter 3 - Lifting the Hood Discovering What Computers Actually Are
Chapter 4 - The Right to Assemble The Process of Making Assembly Language Programs
Chapter 5 - NASM-IDE: A Place to Stand Give me a lever long enough, and a place to stand, and I will move the Earth.
Chapter 6 - An Uneasy Alliance The x86 CPU and Its Segmented Memory System
Chapter 7 - Following Your Instructions Meeting Machine Instructions up Close and Personal
Chapter 8 - Our Object All Sublime Creating Programs that Work
Chapter 9 - Dividing and Conquering Using Procedures and Macros to Battle Complexity
Chapter 10 - Bits, Flags, Branches, and Tables Easing into Mainstream Assembly Programming
Chapter 11 - Stringing Them Up Those Amazing String Instructions
Chapter 12 - The Programmer's View of Linux Tools and Skills to Help You Write Assembly Code under a True 32-Bit OS
Chapter 13 - Coding for Linux Applying What You've Learned to a True Protected Mode Operating System
Conclusion - Not the End, But Only the Beginning
Appendix A - Partial 8086/8088 Instruction Set Reference
Appendix B - Segment Register Assumptions for Real Mode Segmented Model Appendix C - Web URLs for Assembly Programmers
Appendix D - Segment Register Assumptions
Appendix E - What's on the CD-ROM?
Index
List of Figures
List of Tables
Back Cover
The bestselling guide to assembly language--now updated and expanded to include coverage of Linux.
This new edition of the bestselling guide to assembly programming now covers DOS and Linux! The Second Edition begins with a highly accessible overview of the internal operations of the Intel-based PC and systematically covers all the steps involved in writing, testing, and debugging assembly programs.
Expert author Jeff Duntemann then presents working example programs for both the DOS and Linux operating systems using the popular free assembler NASM. He also inlcudes valuable infomation on how to use procedures and macros, plus rare explanations of assembly-level coding for Linux, all of which combine to offer a comprehensive look at the complexitites of assembly programming for Intel processors.
Providing you with the foundation to create executable assembly language programs, this book:
Explains how to use NASM-IDE, a simple program editor and assembly-oriented development environment
Details the most used elements of the 86-family instruction set
Teaches about DEBUG, the single most useful tool you have as an assembly language programmer Examines the operations that machine instructions force the CPU to perform
Discusses the process of memory addressing
Covers coding for Linux
About the Author
Jeff Duntemann is the Editor-in-Chief of Visual Developer Techniques, the "Structured Programming" columnist for than twenty programming books.
magazine, former editor of Turbo Technix and PC Dr. Dobb’s Journal, and has written and edited more
Assembly Language Step-by-Step—Programming
with DOS and Linux, Second Edition
Jeff Duntemann
Wiley Computer Publishing John Wiley & Sons, Inc.
NEW YORK • CHICHESTER • WEINHEIM • BRISBANE • SINGAPORE • TORONTO
Publisher: Robert Ipsen
Editor: Cary Sullivan
Managing Editor: Micheline Frederick
Text Design & Composition: North Market Street Graphics
Designations used by companies to distinguish their products are often claimed as trademarks. In all instances where John Wiley & Sons, Inc., is aware of a claim, the product names appear in initial capital or ALL CAPITAL LETTERS. Readers, however, should contact the appropriate companies for more complete information regarding trademarks and registration.
Copyright © 2000 by Jeff Duntemann.
All rights reserved.
Published by John Wiley & Sons, Inc.
Published simultaneously in Canada.
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) 750-4744. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 605 Third Avenue, New York, NY 10158-0012, (212) 850-6011, fax (212) 850-6008, E-Mail: <PERMREQ @ WILEY.COM>.
This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold with the understanding that the publisher is not engaged in professional services. If professional advice or other expert assistance is required, the services of a competent professional person should be sought.
Library of Congress Cataloging-in-Publication Data:
Duntemann, Jeff.
Assembly language step-by-step : programming with DOS and Linux / Jeff Duntemann.—2nd ed. p. cm.
Rev. ed. of: Assembly language, © 1992.
ISBN 0-471-37523-3 (paper/CD-ROM : alk. paper)
1. Assembler language (Computer program language)I. Duntemann, Jeff. Assembly language.II. Title.
QA76.73.A8 D88 2000 005.265—dc21 00-020611
10 9 8 7 6 5 4 3 2 1
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!
Acknowledgments
First of all, to the authors of the software that I am honored to provide by their permission on this book's CD-ROM:
Robert Anderton, author of NASM-IDE: www.inglenook.co.uk/nasmide/
Anthony Williams, author of ALINK: http://alink.home.dhs.org/
And, of course, the NASM team: Julian "Jules" Hall, Simon Tatham, H. Peter Anvin, John Fine, Kendall Bennet, Gary Clark, and Andrew Crabtree: www.web-sites.co.uk/nasm/
Because of their generosity, there is "nothing else to buy." Everything you need to program in assembly is right here on the CD-ROM for this book.
Abundant thanks also go to Bill Schindler, for teaching me the ways of the C library, and Michael Abrash, who has always has been the rock upon whom my knowledge of assembly language itself has been anchored.
Finally, to Carol, as always, for the sacramental friendship that has challenged me, shaped me, and redeemed me every day of our 30 years together and 23 years as spouses.