Preface vii Chapter 1 Representing Data in a Computer 1 1.1 Binary and Hexadecimal Numbers 2 1.2 Character Codes 6 1.3 2's Complement Representation for Signed Integers 9 1.4 Addition and Subtraction of 2's Complement Numbers 15 1.5 Other Systems for Representing Numbers 21 Chapter Summary 25 Chapter 2 Parts of a Computer System 27 2.1 PC Hardware: Memory 28 2.2 PC Hardware: The CPU 30 2.3 PC Hardware: Input/Output Devices 36 2.4 PC Software 37 PC Software: The Operating System 37 PC Software: Text Editors 38 PC Software: Language Translators and the Linker 38 Chapter Summary 39 Chapter 3 Elements of Assembly Language 41 3.1 Assembly Language Statements 42 3.2 A Complete Example 45 3.3 How to Assemble, Link, and Run a Program 53 3.4 The Assembler Listing File 60 3.5 Constant Operands 68 3.6 Instruction Operands 73 3.7 Input/Output Using Macros Defined in IO.H 77 Chapter Summary 82 Chapter 4 Basic Instructions 85 4.1 Copying Data 86 4.2 Integer Addition and Subtraction Instructions 95 4.3 Multiplication Instructions 108 4.4 Division Instructions 118 4.5 Addition and Subtraction of Larger Numbers 130 4.6 Something Extra: Levels of Abstraction and Microcode 133 Chapter Summary 134 Chapter 5 Branching and Looping 137 5.1 Unconditional Jumps 138 5.2 Conditional Jumps, Compare Instructions, and if Structures 144 5.3 Implementing Loop Structures 159 5.4 for Loops in Assembly Language 173 5.5 Arrays 180 5.6 Something Extra: Pipelining 189 Chapter Summary 190 Chapter 6 Procedures 193 6.1 The 80x86 Stack 194 6.2 Procedure Body, Call and Return 201 6.3 Parameters and Local Variables 211 6.4 Recursion 223 6.5 Other Architectures: Procedures Without a Stack 228 Chapter Summary 230 Chapter 7 String Operations 231 7.1 Using String Instructions 232 7.2 Repeat Prefixes and More String Instructions 239 7.3 Character Translation 254 7.4 Converting a 2's Complement Integer to an ASCII String 259 7.5 Other Architectures: CISC versus RISC Designs 264 Chapter Summary 265 Chapter 8 Bit Manipulation 267 8.1 Logical Operations 268 8.2 Shift and Rotate Instructions 278 8.3 Converting an ASCII String to a 2's Complement Integer 292 8.4 The Hardware Level--Logic Gates 298 Chapter Summary 299 Chapter 9 The Assembly Process 301 9.1 Two-Pass and One-Pass Assembly 302 9.2 80x86 Instruction Coding 307 9.3 Macro Definition and Expansion 319 9.4 Conditional Assembly 326 9.5 Macros in IO.H 333 Chapter Summary 337 Chapter 10 Floating-Point Arithmetic 339 10.1 80x86 Floating-Point Architecture 340 10.2 Programming with Floating-Point Instructions 359 10.3 Floating-Point Emulation 374 10.4 Floating-Point and In-line Assembly 384 Chapter Summary 386 Chapter 11 Decimal Arithmetic 387 11.1 Packed BCD Representations 388 11.2 Packed BCD Instructions 396 11.3 Unpacked BCD Representations and Instructions 404 11.4 Other Architectures: VAX Packed Decimal Instructions 416 Chapter Summary 417 Chapter 12 Input/Output 419 12.1 Console I/O Using the Keme132 Library 420 12.2 Sequential Ffie I/O Using the Kernel32 Library 428 12.3 Lower-Level Input/Output 437 Chapter Summary 439 Appendix A Hexadecimal/ASCII Conversion 441 Appendix B Useful MS-DOS Commands 443 Appendix C MASM 6.11 Reserved Words 445 Appendix D 80x86 Instructions (by Mnemonic) 449 Appendix E 80x86 Instructions (by Opcode) 469 Index 489