Preface xxiii 1 Basic Concepts 1 1.1 Welcome to Assembly Language 1 1.1.1 Questions You Might Ask 3 1.1.2 Assembly Language Applications 6 1.1.3 Section Review 6 1.
2 Virtual Machine Concept 7 1.2.1 Section Review 9 1.3 Data Representation 9 1.3.1 Binary Integers 10 1.3.2 Binary Addition 12 1.
3.3 Integer Storage Sizes 13 1.3.4 Hexadecimal Integers 13 1.3.5 Hexadecimal Addition 15 1.3.6 Signed Binary Integers 16 1.
3.7 Binary Subtraction 18 1.3.8 Character Storage 19 1.3.9 Section Review 21 1.4 Boolean Expressions 22 1.4.
1 Truth Tables for Boolean Functions 24 1.4.2 Section Review 26 1.5 Chapter Summary 26 1.6 Key Terms 27 1.7 Review Questions and Exercises 28 1.7.1 Short Answer 28 1.
7.2 Algorithm Workbench 30 2 x86 Processor Architecture 32 2.1 General Concepts 33 2.1.1 Basic Microcomputer Design 33 2.1.2 Instruction Execution Cycle 34 2.1.
3 Reading from Memory 36 2.1.4 Loading and Executing a Program 36 2.1.5 Section Review 37 2.2 32-Bit x86 Processors 37 2.2.1 Modes of Operation 37 2.
2.2 Basic Execution Environment 38 2.2.3 x86 Memory Management 41 2.2.4 Section Review 42 2.3 64-Bit x86-64 Processors 42 2.3.
1 64-Bit Operation Modes 43 2.3.2 Basic 64-Bit Execution Environment 43 2.4 Components of a Typical x86 Computer 44 2.4.1 Motherboard 44 2.4.2 Memory 46 2.
4.3 Section Review 46 2.5 Input--Output System 47 2.5.1 Levels of I/O Access 47 2.5.2 Section Review 49 2.6 Chapter Summary 50 2.
7 Key Terms 51 2.8 Review Questions 52 3 Assembly Language Fundamentals 53 3.1 Basic Language Elements 54 3.1.1 First Assembly Language Program 54 3.1.2 Integer Literals 55 3.1.
3 Constant Integer Expressions 56 3.1.4 Real Number Literals 57 3.1.5 Character Literals 57 3.1.6 String Literals 58 3.1.
7 Reserved Words 58 3.1.8 Identifiers 58 3.1.9 Directives 59 3.1.10 Instructions 60 3.1.
11 Section Review 63 3.2 Example: Adding and Subtracting Integers 63 3.2.1 The AddTwo Program 63 3.2.2 Running and Debugging the AddTwo Program 65 3.2.3 Program Template 70 3.
2.4 Section Review 70 3.3 Assembling, Linking, and Running Programs 71 3.3.1 The Assemble-Link-Execute Cycle 71 3.3.2 Listing File 71 3.3.
3 Section Review 73 3.4 Defining Data 74 3.4.1 Intrinsic Data Types 74 3.4.2 Data Definition Statement 74 3.4.3 Adding a Variable to the AddTwo Program 75 3.
4.4 Defining BYTE and SBYTE Data 76 3.4.5 Defining WORD and SWORD Data 78 3.4.6 Defining DWORD and SDWORD Data 79 3.4.7 Defining QWORD Data 79 3.
4.8 Defining Packed BCD (TBYTE) Data 80 3.4.9 Defining Floating-Point Types 81 3.4.10 A Program That Adds Variables 81 3.4.11 Little-Endian Order 82 3.
4.12 Declaring Uninitialized Data 83 3.4.13 Section Review 83 3.5 Symbolic Constants 84 3.5.1 Equal-Sign Directive 84 3.5.
2 Calculating the Sizes of Arrays and Strings 85 3.5.3 EQU Directive 86 3.5.4 TEXTEQU Directive 87 3.5.5 Section Review 88 3.6 64-Bit Programming 88 3.
7 Chapter Summary 90 3.8 Key Terms 91 3.8.1 Terms 91 3.8.2 Instructions, Operators, and Directives 92 3.9 Review Questions and Exercises 92 3.9.
1 Short Answer 92 3.9.2 Algorithm Workbench 93 3.10 Programming Exercises 94 4 Data Transfers, Addressing, and Arithmetic 95 4.1 Data Transfer Instructions 96 4.1.1 Introduction 96 4.1.
2 Operand Types 96 4.1.3 Direct Memory Operands 96 4.1.4 MOV Instruction 98 4.1.5 Zero/Sign Extension of Integers 99 4.1.
6 LAHF and SAHF Instructions 101 4.1.7 XCHG Instruction 102 4.1.8 Direct-Offset Operands 102 4.1.9 Example Program (Moves) 103 4.1.
10 Section Review 104 4.2 Addition and Subtraction 105 4.2.1 INC and DEC Instructions 105 4.2.2 ADD Instruction 105 4.2.3 SUB Instruction 106 4.
2.4 NEG Instruction 106 4.2.5 Implementing Arithmetic Expressions 106 4.2.6 Flags Affected by Addition and Subtraction 107 4.2.7 Example Program (AddSubTest) 111 4.
2.8 Section Review 112 4.3 Data-Related Operators and Directives 112 4.3.1 OFFSET Operator 112 4.3.2 ALIGN Directive 113 4.3.
3 PTR Operator 114 4.3.4 TYPE Operator 115 4.3.5 LENGTHOF Operator 116 4.3.6 SIZEOF Operator 116 4.3.
7 LABEL Directive 116 4.3.8 Section Review 117 4.4 Indirect Addressing 117 4.4.1 Indirect Operands 117 4.4.2 Arrays 118 4.
4.3 Indexed Operands 119 4.4.4 Pointers 121 4.4.5 Section Review 122 4.5 JMP and LOOP Instructions 123 4.5.
1 JMP Instruction 123 4.5.2 LOOP Instruction 124 4.5.3 Displaying an Array in the Visual Studio Debugger 125 4.5.4 Summing an Integer Array 126 4.5.
5 Copying a String 127 4.5.6 Section Review 128 4.6 64-Bit Programming 128 4.6.1 MOV Instruction 128 4.6.2 64-Bit Version of SumArray 130 4.
6.3 Addition and Subtraction 130 4.6.4 Section Review 131 4.7 Chapter Summary 132 4.8 Key Terms 133 4.8.1 Terms 133 4.
8.2 Instructions, Operators, and Directives 133 4.9 Review Questions and Exercises 134 4.9.1 Short Answer 134 4.9.2 Algorithm Workbench 136 4.10 Programming Exercises 137 5 Procedures 139 5.
1 Stack Operations 140 5.1.1 Runtime Stack (32-bit mode) 140 5.1.2 PUSH and POP Instructions 142 5.1.3 Section Review 145 5.2 Defining and Using Procedures 145 5.
2.1 PROC Directive 145 5.2.2 CALL and RET Instructions 147 5.2.3 Nested Procedure Calls 148 5.2.4 Passing Register Arguments to Procedures 150 5.
2.5 Example: Summing an Integer Array 150 5.2.6 Saving and Restoring Registers 152 5.2.7 Section Review 153 5.3 Linking to an External Library 153 5.3.
1 Background Information 154 5.3.2 Section Review 155 5.4 The Irvine32 Library 155 5.4.1 Motivation for Creating the Library 155 5.4.2 Overview 157 5.
4.3 Individual Procedure Descriptions 158 5.4.4 Library Test Programs 170 5.4.5 Section Review 178 5.5 64-Bit Assembly Programming 178 5.5.
1 The Irvine64 Library 178 5.5.2 Calling 64-Bit Subroutines 179 5.5.3 The x64 Calling Convention 179 5.5.4 Sample Program that Calls a Procedure 180 5.6 Chapter Summary 182 5.
7 Key Terms 183 5.7.1 Terms 183 5.7.2 Instructions, Operators, and Directives 183 5.8 Review Questions and Exercises 183 5.8.1 Short Answer 183 5.
8.2 Algorithm Workbench 186 5.9 Programming Exercises 187 6 Conditional Processing 189 6.1 Conditional Branching 190 6.2 Boolean and Comparison Instructions 190 6.2.1 The CPU Status Flags 191 6.2.
2 AND Instruction 191 6.2.3 OR Instruction 192 6.2.4 Bit-Mapped Sets 194 6.2.5 XOR Instruction 195 6.2.
6 NOT Instruction 196 6.2.7 TEST Instruction 196 6.2.8 CMP Instruction 197 6.2.9 Setting and Clearing Individual CPU Flags 198 6.2.
10 Boolean Instructions in 64-Bit Mode 199 6.2.11 Section Review 199 6.3 Conditional Jumps 199 6.3.1 Conditional Structures 199 6.3.2 J cond Instruction 200 6.
3.3 Types of Conditional Jump Instructions 201 6.3.4 Conditional Jump Applications 204 6.3.5 Section Review 208 6.4 Conditional Loop Instructions 209 6.4.
1 LOOPZ and LOOPE Instructions 209 6.4.2 LOOPNZ and LOOPNE Instructions 209 6.4.3 Section Review 210 6.5 Conditional Structures 210 6.5.1 Block-Structured IF Statements 210 6.
5.2 Compound Expressions 213 6.5.3 WHILE Loops 214 6.5.4 Table-Driven Selection 216 6.5.5 Section Review 219 6.
6 Application: Finite-State Machines 219 6.6.1 Validating an Input String 219 6.6.2 Validating a Signed Integer 220 6.6.3 Section Review 224 6.7 Conditional Control Flow Directives 225 6.
7.1 Creating IF Statements 226 6.7.2 Signed and Unsigned Comparisons 227 6.7.3 Compound Expressions 228 6.7.4 Creating Loops with .
REPEAT and .WHILE 231 6.8 Chapter Summary 232 6.9 Key Terms 233 6.9.1 Terms 233 6.9.2 Instructions, Operators, and Directives 234 6.
10 Review Questions and Exercises 234 6.10.1 Short Answer 234 6.10.2 Algorithm Workbench 236 6.11 Programming Exercises 237 6.11.1 Suggestions for Testing Your Code 237 6.
11.2 Exercise Descriptions 238 7 Integer Arithmetic 242 7.1 Shift and Rotate Instructions 243 7.1.1 Logical Shifts and Arithmetic Shifts 243 7.1.2 SHL Instruction 244 7.1.
3 SHR Instruction 245 7.1.4 SAL and SAR Instructions 246 7.1.5 ROL Instruction 247 7.1.6 ROR Instruction 247 7.1.
7 RCL and RCR Instructions 248 7.1.8 Signed Overflow 249 7.1.9 SHLD/SHRD Instructions 249 7.1.10 Section Review 251 7.2 Shift and Rotate Applications 251 7.
2.1 Shifting Multiple Doublewords 252 7.2.2 Binary Multiplication 253 7.2.3 Displaying Binary Bits 254 7.2.4 Extracting File Date Fields 254 7.
2.5 Section Review 255 7.3 Multiplication and Division Instructions 255 7.3.1 MUL Instruction.