Preface |
|
xvii | |
Chapter 1 Number Systems and Number Representations |
|
1 | (50) |
|
|
1 | (25) |
|
1.1.1 Binary Number System |
|
|
4 | (2) |
|
1.1.2 Octal Number System |
|
|
6 | (2) |
|
1.1.3 Decimal Number System |
|
|
8 | (1) |
|
1.1.4 Hexadecimal Number System |
|
|
9 | (3) |
|
1.1.5 Arithmetic Operations |
|
|
12 | (8) |
|
1.1.6 Conversion between Radices |
|
|
20 | (6) |
|
1.2 Number Representations |
|
|
26 | (21) |
|
|
26 | (2) |
|
1.2.2 Diminished-Radix Complement |
|
|
28 | (3) |
|
|
31 | (1) |
|
1.2.4 Arithmetic Operations |
|
|
32 | (15) |
|
|
47 | (4) |
Chapter 2 X86 Processor Architecture |
|
51 | (36) |
|
|
51 | (1) |
|
2.2 Arithmetic and Logic Unit |
|
|
52 | (2) |
|
|
54 | (1) |
|
|
55 | (10) |
|
|
55 | (1) |
|
|
56 | (5) |
|
|
61 | (4) |
|
|
65 | (3) |
|
|
65 | (1) |
|
|
66 | (2) |
|
|
68 | (12) |
|
2.6.1 General-Purpose Registers |
|
|
70 | (1) |
|
|
71 | (1) |
|
|
72 | (2) |
|
2.6.4 Instruction Pointer |
|
|
74 | (1) |
|
2.6.5 Floating-Point Registers |
|
|
75 | (5) |
|
2.7 Translation Lookaside Buffer |
|
|
80 | (1) |
|
|
81 | (2) |
|
2.8.1 The Assembly Process |
|
|
82 | (1) |
|
|
83 | (4) |
Chapter 3 Addressing Modes |
|
87 | (14) |
|
|
88 | (1) |
|
|
88 | (1) |
|
3.3 Direct Memory Addressing |
|
|
89 | (1) |
|
3.4 Base (Register Indirect) Memory Addressing |
|
|
89 | (1) |
|
3.5 Base or Index Plus Displacement Addressing |
|
|
90 | (2) |
|
3.6 Base and Index Plus Displacement Addressing |
|
|
92 | (2) |
|
|
94 | (2) |
|
3.8 Segment Override Prefix |
|
|
96 | (1) |
|
|
96 | (1) |
|
|
96 | (1) |
|
|
97 | (1) |
|
|
97 | (4) |
Chapter 4 C Programming Fundamentals |
|
101 | (92) |
|
4.1 Structure of a C Program |
|
|
101 | (3) |
|
4.2 Variables and Constants |
|
|
104 | (9) |
|
|
104 | (3) |
|
|
107 | (6) |
|
|
113 | (7) |
|
4.3.1 The Printf()Function |
|
|
113 | (4) |
|
4.3.2 The Scanf()Function |
|
|
117 | (3) |
|
|
120 | (40) |
|
4.4.1 Arithmetic Operators |
|
|
121 | (11) |
|
4.4.2 Relational Operators |
|
|
132 | (3) |
|
|
135 | (4) |
|
|
139 | (6) |
|
|
145 | (3) |
|
4.4.6 Conditional Operator |
|
|
148 | (3) |
|
4.4.7 Increment and Decrement Operators |
|
|
151 | (5) |
|
|
156 | (4) |
|
|
160 | (3) |
|
|
163 | (3) |
|
4.7 Additional C Constructs |
|
|
166 | (17) |
|
|
167 | (5) |
|
|
172 | (7) |
|
|
179 | (1) |
|
|
180 | (3) |
|
|
183 | (10) |
Chapter 5 Data Transfer Instructions |
|
193 | (38) |
|
|
193 | (4) |
|
5.1.1 Signed Binary Integers |
|
|
193 | (1) |
|
5.1.2 Unsigned Binary Integers |
|
|
194 | (1) |
|
5.1.3 Unpacked and Packed BCD Integers |
|
|
195 | (1) |
|
5.1.4 Floating-Point Numbers |
|
|
196 | (1) |
|
|
197 | (9) |
|
5.2.1 General Move Instructions |
|
|
198 | (5) |
|
5.2.2 Move with Sign/Zero Extension |
|
|
203 | (1) |
|
|
204 | (2) |
|
5.3 Load Effective Address |
|
|
206 | (1) |
|
5.4 Load Segment Registers |
|
|
207 | (2) |
|
5.5 Exchange Instructions |
|
|
209 | (11) |
|
|
209 | (4) |
|
|
213 | (2) |
|
|
215 | (2) |
|
5.5.4 Compare and Exchange |
|
|
217 | (3) |
|
|
220 | (5) |
|
5.7 Conversion Instructions |
|
|
225 | (4) |
|
|
229 | (2) |
Chapter 6 Branching and Looping Instructions |
|
231 | (40) |
|
6.1 Branching Instructions |
|
|
232 | (19) |
|
6.1.1 Unconditional Jump Instruction |
|
|
232 | (5) |
|
6.1.2 Compare Instruction |
|
|
237 | (4) |
|
6.1.3 Conditional Jump Instructions |
|
|
241 | (10) |
|
|
251 | (15) |
|
|
251 | (3) |
|
|
254 | (2) |
|
6.2.3 Implementing while Loops |
|
|
256 | (4) |
|
6.2.4 Implementing for Loops |
|
|
260 | (6) |
|
|
266 | (5) |
Chapter 7 Stack Operations |
|
271 | (14) |
|
|
272 | (8) |
|
7.2 Additional Push Instructions |
|
|
280 | (1) |
|
7.3 Additional Pop Instructions |
|
|
281 | (1) |
|
|
282 | (3) |
Chapter 8 Logical, Bit, Shift, and Rotate Instructions |
|
285 | (62) |
|
8.1 Logical AND Instruction |
|
|
285 | (6) |
|
8.2 Logical Inclusive-OR Instruction |
|
|
291 | (3) |
|
8.3 Logical Exclusive-OR Instruction |
|
|
294 | (4) |
|
8.4 Logical NOT Instruction - 1s Complement |
|
|
298 | (1) |
|
8.5 NEG Instruction 2s Complement |
|
|
299 | (5) |
|
8.6 TEST and Byte Set on Condition Instructions |
|
|
304 | (1) |
|
|
304 | (1) |
|
8.6.2 Set Byte on Condition (SETcc) Instruction |
|
|
304 | (1) |
|
8.7 Bit Test Instructions |
|
|
305 | (9) |
|
8.7.1 Bit Test (BT) Instruction |
|
|
305 | (1) |
|
8.7.2 Bit Test and Set (BTS) Instruction |
|
|
306 | (1) |
|
8.7.3 Bit Test and Reset (BTR) Instruction |
|
|
306 | (1) |
|
8.7.4 Bit Test and Complement (BTC) Instruction |
|
|
307 | (7) |
|
8.8 Bit Scan Instructions |
|
|
314 | (6) |
|
8.8.1 Bit Scan Forward (BSF) Instruction |
|
|
314 | (3) |
|
8.8.2 Bit Scan Reverse (BSR) Instruction |
|
|
317 | (3) |
|
|
320 | (13) |
|
8.9.1 Shift Arithmetic Left (SAL) Instruction |
|
|
320 | (3) |
|
8.9.2 Shift Logical Left (SHL) Instruction |
|
|
323 | (1) |
|
8.9.3 Shift Arithmetic Right (SAR) Instruction |
|
|
324 | (2) |
|
8.9.4 Shift Logical Right (SHR) Instruction |
|
|
326 | (1) |
|
8.9.5 Shift Left Double (SHLD) Instruction |
|
|
327 | (4) |
|
8.9.6 Shift Right Double (SHRD) Instruction |
|
|
331 | (2) |
|
|
333 | (10) |
|
8.10.1 Rotate Left (ROL) Instruction |
|
|
334 | (1) |
|
8.10.2 Rotate through Carry Left (RCL) Instruction |
|
|
335 | (4) |
|
8.10.3 Rotate Right (ROR) Instruction |
|
|
339 | (1) |
|
8.10.4 Rotate through Carry Right (RCR) Instruction |
|
|
339 | (4) |
|
|
343 | (4) |
Chapter 9 Fixed-Point Arithmetic Instructions |
|
347 | (62) |
|
|
347 | (16) |
|
9.1.1 Add (ADD) Instruction |
|
|
349 | (3) |
|
9.1.2 Add with Carry (ADC) Instruction |
|
|
352 | (6) |
|
9.1.3 Increment by 1(INC) Instruction |
|
|
358 | (5) |
|
|
363 | (14) |
|
9.2.1 Subtract (SUB) Instruction |
|
|
366 | (3) |
|
9.2.2 Integer Subtraction with Borrow (SBB) Instruction |
|
|
369 | (1) |
|
9.2.3 Decrement by 1(DEC) Instruction |
|
|
370 | (7) |
|
9.2.4 Two's Complement Negation (NEG) Instruction |
|
|
377 | (1) |
|
|
377 | (12) |
|
9.3.1 Unsigned Multiply (MUL) Instruction |
|
|
378 | (4) |
|
9.3.2 Signed Multiply (IMUL) Instruction |
|
|
382 | (7) |
|
|
389 | (9) |
|
9.4.1 Unsigned Divide (DIV) Instruction |
|
|
391 | (3) |
|
9.4.2 Signed Divide (IDIV) Instruction |
|
|
394 | (4) |
|
|
398 | (11) |
Chapter 10 Binary-Coded Decimal Arithmetic Instructions |
|
409 | (36) |
|
10.1 ASCII Adjust after Addition (AAA) Instruction |
|
|
411 | (3) |
|
10.2 Decimal Adjust AL after Addition (DAA) Instruction |
|
|
414 | (7) |
|
10.3 ASCII Adjust AL after Subtraction (AAS) Instruction |
|
|
421 | (3) |
|
10.4 Decimal Adjust AL after Subtraction (DAS) Instruction |
|
|
424 | (3) |
|
10.5 ASCII Adjust AX after Multiplication (AAM) Instruction |
|
|
427 | (8) |
|
10.6 ASCII Adjust AX before Division (AAD) Instruction |
|
|
435 | (5) |
|
|
440 | (5) |
Chapter 11 Floating-Point Arithmetic Instructions |
|
445 | (84) |
|
11.1 Floating-Point Fundamentals |
|
|
446 | (5) |
|
|
449 | (2) |
|
11.2 Load Data instructions |
|
|
451 | (5) |
|
11.2.1 Load Floating-Point Value (FLD) Instructions |
|
|
451 | (2) |
|
11.2.2 Load Constant Instructions |
|
|
453 | (1) |
|
11.2.3 Load X87 FPU Control Word (FLDCW) Instruction |
|
|
454 | (1) |
|
11.2.4 Load X87 FPU Environment (FLDENV) Instruction |
|
|
455 | (1) |
|
11.2.5 Load Integer (FILD) Instruction |
|
|
455 | (1) |
|
11.2.6 Load Binary-Coded Decimal (FBLD) Instruction |
|
|
455 | (1) |
|
11.3 Store Data Instructions |
|
|
456 | (7) |
|
11.3.1 Store BCD Integer and Pop (FBSTP) Instruction |
|
|
456 | (1) |
|
11.3.2 Store Integer (FIST) Instruction |
|
|
456 | (1) |
|
11.3.3 Store Integer and Pop (FISTP) Instruction |
|
|
456 | (1) |
|
11.3.4 Store Integer with Truncation and Pop (FISTTP) Instruction |
|
|
457 | (2) |
|
11.3.5 Store Floating-Point Value (FST) Instruction |
|
|
459 | (2) |
|
11.3.6 Store Floating-Point Value and Pop (FSTP) Instruction |
|
|
461 | (1) |
|
11.3.7 Store X87 FPU Control Word (FSTCW) Instruction |
|
|
461 | (1) |
|
11.3.8 Store X87 FPU Environment (FSTENV) Instruction |
|
|
462 | (1) |
|
11.3.9 Store X87 FPU Status Word (FSTSW) Instruction |
|
|
462 | (1) |
|
11.4 Addition Instructions |
|
|
463 | (6) |
|
11.4.1 Overflow and Underflow |
|
|
465 | (1) |
|
|
466 | (3) |
|
11.5 Subtraction Instructions |
|
|
469 | (9) |
|
11.5.1 Numerical Examples |
|
|
470 | (2) |
|
11.5.2 Subtract Instructions |
|
|
472 | (6) |
|
11.6 Multiplication Instructions |
|
|
478 | (8) |
|
|
478 | (1) |
|
11.6.2 Numerical Examples |
|
|
479 | (2) |
|
11.6.3 Multiply Instructions |
|
|
481 | (5) |
|
11.7 Division Instructions |
|
|
486 | (11) |
|
|
487 | (2) |
|
|
489 | (3) |
|
11.7.3 Divide Instructions |
|
|
492 | (5) |
|
11.8 Compare instructions |
|
|
497 | (6) |
|
11.8.1 Compare Floating-Point Values |
|
|
497 | (2) |
|
11.8.2 Compare Floating-Point Values and Set EFLAGS |
|
|
499 | (2) |
|
|
501 | (1) |
|
|
501 | (1) |
|
11.8.5 Unordered Compare Floating-Point Values |
|
|
501 | (2) |
|
11.9 Trigonometric Instructions |
|
|
503 | (12) |
|
|
503 | (1) |
|
11.9.2 Partial Arctangent |
|
|
504 | (2) |
|
|
506 | (1) |
|
|
507 | (2) |
|
|
509 | (6) |
|
11.10 Additional Instructions |
|
|
515 | (7) |
|
|
515 | (1) |
|
|
516 | (1) |
|
11.10.3 Decrement Stack-Top Pointer |
|
|
516 | (1) |
|
11.10.4 Free Floating-Point Register |
|
|
516 | (1) |
|
11.10.5 Increment Stack-Top Pointer |
|
|
517 | (1) |
|
11.10.6 Partial Remainder |
|
|
517 | (1) |
|
|
517 | (1) |
|
|
518 | (1) |
|
11.10.9 Exchange Register Contents |
|
|
519 | (3) |
|
|
522 | (7) |
Chapter 12 Procedures |
|
529 | (14) |
|
|
530 | (1) |
|
12.2 Return from a Procedure |
|
|
531 | (1) |
|
12.3 Passing Parameters to a Procedure |
|
|
531 | (9) |
|
|
540 | (3) |
Chapter 13 String Instructions |
|
543 | (32) |
|
|
544 | (5) |
|
|
545 | (1) |
|
|
546 | (1) |
|
13.1.3 REPNE/REPNZ Prefix |
|
|
547 | (2) |
|
13.2 Move String Instructions |
|
|
549 | (5) |
|
13.2.1 Move Data from String to String (Explicit Operands) Instructions |
|
|
550 | (1) |
|
13.2.2 Move Data from String to String (No Operands) Instructions |
|
|
551 | (3) |
|
13.3 Load String Instructions |
|
|
554 | (4) |
|
13.3.1 Load String (Explicit Operands) Instructions |
|
|
555 | (1) |
|
13.3.2 Load String (No Operands) Instructions |
|
|
555 | (3) |
|
13.4 Store String Instructions |
|
|
558 | (2) |
|
13.4.1 Store String (Explicit Operands) Instructions |
|
|
558 | (1) |
|
13.4.2 Store String (No Operands) Instructions |
|
|
558 | (2) |
|
13.5 Compare Strings Instructions |
|
|
560 | (4) |
|
13.5.1 Compare Strings (Explicit Operands) Instructions |
|
|
561 | (1) |
|
13.5.2 Compare Strings (No Operands) Instructions |
|
|
561 | (3) |
|
13.6 Scan String Instructions |
|
|
564 | (2) |
|
13.6.1 Scan String (Explicit Operands) Instructions |
|
|
564 | (1) |
|
13.6.2 Scan String (No Operands) Instructions |
|
|
565 | (1) |
|
|
566 | (9) |
Chapter 14 Arrays |
|
575 | (18) |
|
14.1 One-Dimensional Arrays |
|
|
575 | (11) |
|
14.1.1 One-Dimensional Arrays in C |
|
|
582 | (4) |
|
14.2 Multidimensional Arrays |
|
|
586 | (4) |
|
|
590 | (3) |
Chapter 15 Macros |
|
593 | (24) |
|
|
593 | (4) |
|
|
597 | (17) |
|
|
614 | (3) |
Chapter 16 Interrupts and Input/Output Operations |
|
617 | (12) |
|
|
617 | (2) |
|
16.2 Direct Memory Access |
|
|
619 | (3) |
|
|
622 | (1) |
|
|
623 | (5) |
|
16.4.1 Register I/O IN Instructions |
|
|
624 | (1) |
|
16.4.2 Register I/O OUT Instructions |
|
|
625 | (1) |
|
16.4.3 String I/O IN Instructions |
|
|
625 | (2) |
|
16.4.4 String I/O OUT Instructions |
|
|
627 | (1) |
|
|
628 | (1) |
Chapter 17 Additional Programming Examples |
|
629 | (52) |
|
17.1 Programming Examples |
|
|
629 | (48) |
|
|
677 | (4) |
Appendix A ASCII Character Codes |
|
681 | (2) |
Appendix B Answers to Select Problems |
|
683 | (98) |
|
Chapter 1 Number Systems and Number Representations |
|
|
683 | (2) |
|
Chapter 2 X86 Processor Architecture |
|
|
685 | (1) |
|
Chapter 3 Addressing Modes |
|
|
686 | (1) |
|
Chapter 4 C Programming Fundamentals |
|
|
687 | (6) |
|
Chapter 5 Data Transfer Instructions |
|
|
693 | (5) |
|
Chapter 6 Branching and Looping Instructions |
|
|
698 | (1) |
|
Chapter 7 Stack Operations |
|
|
699 | (3) |
|
Chapter 8 Logical, Bit, Shift, and Rotate Instructions |
|
|
702 | (7) |
|
Chapter 9 Fixed-Point Arithmetic Instructions |
|
|
709 | (14) |
|
Chapter 10 Binary-Coded Decimal Arithmetic Instructions |
|
|
723 | (12) |
|
Chapter 11 Floating-Point Arithmetic Instructions |
|
|
735 | (12) |
|
|
747 | (4) |
|
Chapter 13 String Instructions |
|
|
751 | (4) |
|
|
755 | (4) |
|
|
759 | (9) |
|
Chapter 16 Interrupts and Input/Output Operations |
|
|
768 | (1) |
|
Chapter 17 Additional Programming Examples |
|
|
769 | (12) |
Index |
|
781 | |