- •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
List of Figures
Chapter 1: Another Pleasant Valley Saturday Understanding What Computers Really Do
Figure 1.1: The Game of Big Bux.
Figure 1.2: The Game of Assembly Language.
Chapter 2: Alien Bases Getting Your Arms around Binary and Hexadecimal
Figure 2.1: The anatomy of n= T=.
Figure 2.2: The anatomy of 76225 octal.
Figure 2.3: The anatomy of 3C0A9H.
Chapter 3: Lifting the Hood Discovering What Computers
Actually Are
Figure 3.1: Transistor switches and memory cells.
Figure 3.2: A RAM chip.
Figure 3.3: A 1-megabyte memory bank.
Figure 3.4: The CPU and memory.
Chapter 4: The Right to Assemble The Process of Making Assembly Language Programs
Figure 4.1: Rotating disk storage.
Figure 4.2: The structure of a DOS text file.
Figure 4.3: What the assembler does.
Figure 4.4: The assembler and linker.
Figure 4.5: The assembly language development process.
Figure 4.6: A hex dump of SAM.TXT.
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.
Figure 5.1: The NASM-IDE environment.
Figure 5.2: A NASM-IDE error message box.
Figure 5.3: When you exit without saving.
Figure 5.4: The error information window appears.
Figure 5.5: Running the executable program file.
Figure 5.6: The Open File dialog box.
Figure 5.7: The Find dialog box.
Figure 5.8: The Replace dialog box.
Figure 5.9: The Environment Options dialog box.
Chapter 6: An Uneasy Alliance The x86 CPU and Its Segmented Memory System
Figure 6.1: The 8080 memory model.
Figure 6.2: The 8080 memory model inside an 8086 memory system.
Figure 6.3: Seeing a megabyte through 64K blinders.
Figure 6.4: Memory addresses versus segment addresses.
Figure 6.5: Segments and offsets.
Figure 6.6: Extending the 16-bit general-purpose registers.
Figure 6.7: 8-bit, 16-bit, and 32-bit registers.
Figure 6.8: The real mode flat model.
Figure 6.9: The real mode segmented model.
Figure 6.10: The protected mode flat model.
Figure 6.11: The PC's video refresh buffer.
Chapter 7: Following Your Instructions Meeting Machine Instructions up Close and Personal
Figure 7.1: How memory data is addressed.
Chapter 8: Our Object All Sublime Creating Programs that Work
Figure 8.1: The big picture of the real mode stack.
Figure 8.2: How the stack works.
Figure 8.3: The interrupt vector table.
Figure 8.4: Riding the interrupt vector into DOS.
Figure 8.5: Returning home from an interrupt.
Chapter 9: Dividing and Conquering Using Procedures and Macros to Battle Complexity
Figure 9.1: Calling a procedure and returning.
Figure 9.2: Connecting globals and externals.
Figure 9.3: How macros work.
Chapter 10: Bits, Flags, Branches, and Tables Easing into Mainstream Assembly Programming
Figure 10.1: Bit numbering.
Figure 10.2: The anatomy of an AND instruction.
Figure 10.3: Using XOR to zero a register.
Figure 10.4: Using a lookup table.
Figure 10.5: Interrupt 11H configuration information.
Chapter 11: Stringing Them Up Those Amazing String
Instructions
Figure 11.1: Unpacked BCD digits.
Chapter 12: The Programmer's View of Linux Tools and Skills to Help You Write Assembly Code under a True 32-Bit OS
Figure 12.1: How gcc builds Linux executables.
Figure 12.2: The structure of a Linux assembly language program.
Chapter 13: Coding for Linux Applying What You've Learned to a True Protected Mode Operating System
Figure 13.1: A stack frame.
Figure 13.2: Protected mode memory addressing.
Figure 13.3: Linux command-line arguments.
List of Tables
Chapter 2: Alien Bases Getting Your Arms around Binary and Hexadecimal
Table 2.1: Counting in Martian, Base Fooby
Table 2.2: Powers of Fooby
Table 2.3: Counting in Octal, Base 8
Table 2.4: Octal Columns as Powers of Eight
Table 2.5: Counting in Hexadecimal, Base 16
Table 2.6: Hexadecimal Columns as Powers of 16
Table 2.7: Binary Columns as Powers of 2
Chapter 6: An Uneasy Alliance The x86 CPU and Its Segmented Memory System
Table 6.1: Collective Terms for Memory
Chapter 7: Following Your Instructions Meeting Machine Instructions up Close and Personal
Table 7.1: MOV and Its Operands
Table 7.2: Segment Override Prefixes
Table 7.3: Rogue MOV Instructions
Table 7.4: DEBUG's Flag State Symbols
Chapter 10: Bits, Flags, Branches, and Tables Easing into Mainstream Assembly Programming
Table 10.1: The AND Truth Table for Formal Logic
Table 10.2: The AND Truth Table for Assembly Language
Table 10.3: The OR Truth Table for Assembly Language
Table 10.4: The XOR Truth Table for Assembly Language
Table 10.5: The NOT Truth Table for Assembly Language
Table 10.6: Arithmetic Jump Mnemonics and Their Synonyms
Table 10.7: Arithmetic Tests Useful After a CMP Instruction
Table 10.8: Legal PC Display Adapter/Monitor Combinations
Chapter 12: The Programmer's View of Linux Tools and Skills to Help You Write Assembly Code under a True 32-Bit OS
Table 12.1: Format Codes for gdb's Print and x Commands
Table 12.2: Unit Size Codes for gdb's x Command
Chapter 13: Coding for Linux Applying What You've Learned to a
True Protected Mode Operating System
Table 13.1: Protected Mode Memory-Addressing Schemes
Table 13.2: Common printf Formatting Codes
Table 13.3: The Values Contained in the tm Structure
Table 13.4: File Access Codes for Use with fopen