| Preface |
|
vii | |
|
|
|
1 | (45) |
|
|
|
3 | (16) |
|
A User's View of Computer Systems |
|
|
4 | (1) |
|
What Is Assembly Language? |
|
|
5 | (3) |
|
Advantages of High-Level Languages |
|
|
8 | (1) |
|
Why Program in the Assembly Language? |
|
|
9 | (1) |
|
|
|
10 | (1) |
|
Why Learn the Assembly Language? |
|
|
11 | (1) |
|
Performance: C Versus Assembly Language |
|
|
12 | (2) |
|
|
|
12 | (2) |
|
|
|
14 | (1) |
|
|
|
14 | (1) |
|
|
|
15 | (1) |
|
|
|
15 | (4) |
|
Basic Computer Organization |
|
|
19 | (27) |
|
Basic Components of a Computer System |
|
|
20 | (2) |
|
|
|
22 | (2) |
|
|
|
22 | (1) |
|
|
|
23 | (1) |
|
|
|
24 | (4) |
|
|
|
24 | (1) |
|
|
|
25 | (1) |
|
|
|
26 | (1) |
|
|
|
26 | (1) |
|
The Load/Store Architecture |
|
|
26 | (1) |
|
|
|
27 | (1) |
|
|
|
28 | (4) |
|
|
|
28 | (2) |
|
|
|
30 | (2) |
|
|
|
32 | (6) |
|
Two Basic Memory Operations |
|
|
33 | (2) |
|
|
|
35 | (2) |
|
|
|
37 | (1) |
|
|
|
38 | (3) |
|
Performance: Effect of Data Alignment |
|
|
41 | (2) |
|
|
|
43 | (1) |
|
|
|
43 | (3) |
|
PART II: Pentium Assembly Language |
|
|
46 | (299) |
|
|
|
47 | (20) |
|
The Pentium Processor Family |
|
|
47 | (2) |
|
|
|
49 | (4) |
|
|
|
50 | (1) |
|
Pointer and Index Registers |
|
|
50 | (1) |
|
|
|
51 | (2) |
|
|
|
53 | (1) |
|
Protected-Mode Memory Architecture |
|
|
53 | (6) |
|
|
|
54 | (1) |
|
|
|
55 | (2) |
|
Segment Descriptor Tables |
|
|
57 | (1) |
|
|
|
58 | (1) |
|
Real-Mode Memory Architecture |
|
|
59 | (3) |
|
|
|
62 | (1) |
|
Which Segment Register to Use |
|
|
63 | (1) |
|
|
|
64 | (1) |
|
|
|
65 | (1) |
|
|
|
65 | (2) |
|
Overview of Assembly Language |
|
|
67 | (50) |
|
Assembly Language Statements |
|
|
68 | (1) |
|
|
|
69 | (5) |
|
|
|
74 | (4) |
|
|
|
75 | (1) |
|
Immediate Addressing Mode |
|
|
75 | (1) |
|
|
|
76 | (1) |
|
|
|
77 | (1) |
|
Data Transfer Instructions |
|
|
78 | (2) |
|
|
|
78 | (1) |
|
|
|
79 | (1) |
|
|
|
79 | (1) |
|
|
|
80 | (1) |
|
Overview of Assembly Language Instructions |
|
|
80 | (13) |
|
Simple Arithmetic Instructions |
|
|
80 | (3) |
|
|
|
83 | (3) |
|
|
|
86 | (1) |
|
|
|
87 | (2) |
|
|
|
89 | (2) |
|
|
|
91 | (2) |
|
|
|
93 | (2) |
|
|
|
93 | (1) |
|
|
|
94 | (1) |
|
|
|
94 | (1) |
|
|
|
95 | (3) |
|
|
|
98 | (10) |
|
Performance: When to Use XLAT Instruction |
|
|
108 | (2) |
|
|
|
108 | (2) |
|
|
|
110 | (1) |
|
|
|
110 | (1) |
|
|
|
111 | (2) |
|
|
|
113 | (4) |
|
|
|
117 | (50) |
|
|
|
118 | (1) |
|
Pentium Implementation of the Stack |
|
|
118 | (2) |
|
|
|
120 | (3) |
|
|
|
120 | (1) |
|
|
|
121 | (2) |
|
|
|
123 | (1) |
|
Temporary Storage of Data |
|
|
123 | (1) |
|
|
|
124 | (1) |
|
|
|
124 | (1) |
|
|
|
124 | (2) |
|
Pentium Instructions for Procedures |
|
|
126 | (2) |
|
How Is Program Control Transferred? |
|
|
127 | (1) |
|
|
|
128 | (1) |
|
|
|
128 | (18) |
|
|
|
129 | (3) |
|
|
|
132 | (3) |
|
Preserving Calling Procedure State |
|
|
135 | (1) |
|
Which Registers Should Be Saved |
|
|
136 | (1) |
|
ENTER and LEAVE Instructions |
|
|
137 | (1) |
|
|
|
138 | (8) |
|
Handling a Variable Number of Parameters |
|
|
146 | (4) |
|
|
|
150 | (6) |
|
Multiple Source Program Modules |
|
|
156 | (3) |
|
Performance: Procedure Overheads |
|
|
159 | (1) |
|
|
|
159 | (1) |
|
|
|
160 | (1) |
|
|
|
160 | (2) |
|
|
|
162 | (1) |
|
|
|
163 | (4) |
|
|
|
167 | (30) |
|
|
|
167 | (2) |
|
|
|
169 | (4) |
|
|
|
171 | (1) |
|
|
|
171 | (2) |
|
|
|
173 | (1) |
|
|
|
173 | (7) |
|
|
|
180 | (6) |
|
|
|
180 | (1) |
|
|
|
181 | (3) |
|
|
|
184 | (2) |
|
Performance: Usefulness of Addressing Modes |
|
|
186 | (4) |
|
|
|
190 | (1) |
|
|
|
191 | (1) |
|
|
|
192 | (5) |
|
Arithmetic Flags and Instructions |
|
|
197 | (42) |
|
|
|
197 | (14) |
|
|
|
198 | (2) |
|
|
|
200 | (3) |
|
|
|
203 | (2) |
|
|
|
205 | (1) |
|
|
|
206 | (2) |
|
|
|
208 | (1) |
|
|
|
209 | (2) |
|
|
|
211 | (7) |
|
Multiplication Instructions |
|
|
211 | (4) |
|
|
|
215 | (3) |
|
|
|
218 | (6) |
|
|
|
218 | (3) |
|
|
|
221 | (3) |
|
|
|
224 | (8) |
|
|
|
224 | (1) |
|
|
|
225 | (4) |
|
|
|
229 | (3) |
|
Performance: Multiword Multiplication |
|
|
232 | (1) |
|
|
|
233 | (1) |
|
|
|
234 | (1) |
|
|
|
235 | (4) |
|
|
|
239 | (32) |
|
|
|
239 | (3) |
|
|
|
242 | (2) |
|
|
|
244 | (6) |
|
Jumps Based on Single Flags |
|
|
244 | (2) |
|
Jumps Based on Unsigned Comparisons |
|
|
246 | (1) |
|
Jumps Based on Signed Comparisons |
|
|
247 | (2) |
|
A Note on Conditional Jumps |
|
|
249 | (1) |
|
|
|
250 | (2) |
|
Implementing High-Level Language Decision Structures |
|
|
252 | (5) |
|
|
|
252 | (3) |
|
|
|
255 | (2) |
|
|
|
257 | (6) |
|
|
|
263 | (3) |
|
Multiway Conditional Statements |
|
|
266 | (1) |
|
|
|
266 | (2) |
|
|
|
268 | (1) |
|
|
|
269 | (2) |
|
Logical and Bit Operations |
|
|
271 | (30) |
|
|
|
272 | (6) |
|
|
|
272 | (3) |
|
|
|
275 | (1) |
|
|
|
276 | (2) |
|
|
|
278 | (1) |
|
|
|
278 | (1) |
|
|
|
278 | (6) |
|
Logical Shift Instructions |
|
|
279 | (2) |
|
Arithmetic Shift Instructions |
|
|
281 | (1) |
|
Why Use Shifts for Multiplication and Division? |
|
|
282 | (1) |
|
|
|
283 | (1) |
|
|
|
284 | (2) |
|
|
|
284 | (1) |
|
|
|
285 | (1) |
|
Logical Expressions in High-Level Languages |
|
|
286 | (4) |
|
Representation of Boolean Data |
|
|
286 | (1) |
|
|
|
286 | (1) |
|
|
|
287 | (1) |
|
Evaluation of Logical Expressions |
|
|
288 | (2) |
|
|
|
290 | (1) |
|
Bit Test and Modify Instructions |
|
|
291 | (1) |
|
|
|
291 | (1) |
|
|
|
291 | (6) |
|
|
|
297 | (1) |
|
|
|
297 | (2) |
|
|
|
299 | (2) |
|
|
|
301 | (28) |
|
|
|
301 | (2) |
|
Explicitly Storing String Length |
|
|
302 | (1) |
|
Using a Sentinel Character |
|
|
303 | (1) |
|
|
|
303 | (9) |
|
|
|
304 | (1) |
|
|
|
305 | (1) |
|
|
|
306 | (3) |
|
String Compare Instruction |
|
|
309 | (2) |
|
|
|
311 | (1) |
|
|
|
312 | (9) |
|
Testing String Procedures |
|
|
321 | (2) |
|
Performance: Advantage of String Instructions |
|
|
323 | (1) |
|
|
|
324 | (1) |
|
|
|
325 | (1) |
|
|
|
326 | (3) |
|
|
|
329 | (16) |
|
ASCII and BCD Representations of Numbers |
|
|
330 | (1) |
|
|
|
330 | (1) |
|
|
|
330 | (1) |
|
Processing in ASCII Representation |
|
|
331 | (5) |
|
|
|
332 | (1) |
|
|
|
333 | (1) |
|
|
|
334 | (1) |
|
|
|
334 | (1) |
|
Example: Multidigit ASCII Addition |
|
|
335 | (1) |
|
Processing Packed BCD Numbers |
|
|
336 | (4) |
|
|
|
336 | (2) |
|
|
|
338 | (1) |
|
Example: Multibyte Packed BCD Addition |
|
|
338 | (2) |
|
Performance: Decimal Versus Binary Arithmetic |
|
|
340 | (1) |
|
|
|
341 | (1) |
|
|
|
342 | (2) |
|
|
|
344 | (1) |
|
PART III: MIPS Assembly Language |
|
|
345 | (54) |
|
|
|
347 | (14) |
|
|
|
347 | (2) |
|
Evolution of CISC Processors |
|
|
349 | (2) |
|
|
|
351 | (3) |
|
|
|
354 | (4) |
|
|
|
358 | (1) |
|
|
|
359 | (2) |
|
|
|
361 | (38) |
|
|
|
361 | (12) |
|
|
|
362 | (1) |
|
Data Transfer Instructions |
|
|
363 | (1) |
|
|
|
364 | (4) |
|
|
|
368 | (1) |
|
|
|
369 | (1) |
|
|
|
370 | (1) |
|
|
|
371 | (1) |
|
Branch and Jump Instructions |
|
|
371 | (2) |
|
|
|
373 | (5) |
|
|
|
373 | (2) |
|
SPIM Assembler Directives |
|
|
375 | (2) |
|
|
|
377 | (1) |
|
|
|
378 | (8) |
|
|
|
386 | (5) |
|
|
|
391 | (2) |
|
|
|
393 | (1) |
|
|
|
394 | (1) |
|
|
|
395 | (4) |
|
PART IV: Pentium Interrupt Processing |
|
|
399 | (62) |
|
Protected-Mode Interrupt Processing |
|
|
401 | (22) |
|
|
|
401 | (1) |
|
|
|
402 | (1) |
|
Interrupt Processing in the Protected Mode |
|
|
403 | (4) |
|
|
|
407 | (2) |
|
|
|
409 | (1) |
|
|
|
410 | (4) |
|
|
|
410 | (1) |
|
|
|
410 | (1) |
|
|
|
410 | (4) |
|
|
|
414 | (4) |
|
|
|
418 | (1) |
|
|
|
419 | (1) |
|
|
|
420 | (1) |
|
|
|
420 | (3) |
|
|
|
423 | (38) |
|
Interrupt Processing in the Real Mode |
|
|
424 | (1) |
|
|
|
425 | (1) |
|
|
|
426 | (14) |
|
|
|
426 | (1) |
|
|
|
427 | (4) |
|
|
|
431 | (3) |
|
|
|
434 | (6) |
|
Text Output to Display Screen |
|
|
440 | (1) |
|
|
|
441 | (3) |
|
Direct Control of I/O Devices |
|
|
444 | (2) |
|
|
|
444 | (2) |
|
|
|
446 | (3) |
|
8259 Programmable Interrupt Controller |
|
|
446 | (2) |
|
8255 Programmable Peripheral Interface Chip |
|
|
448 | (1) |
|
|
|
449 | (8) |
|
|
|
450 | (2) |
|
|
|
452 | (5) |
|
|
|
457 | (1) |
|
|
|
458 | (1) |
|
|
|
458 | (3) |
|
|
|
461 | (66) |
|
|
|
463 | (20) |
|
|
|
463 | (1) |
|
Recursion in Pentium Assembly Language |
|
|
464 | (7) |
|
Recursion in MIPS Assembly Language |
|
|
471 | (7) |
|
Recursion Versus Iteration |
|
|
478 | (1) |
|
|
|
479 | (1) |
|
|
|
479 | (1) |
|
|
|
479 | (4) |
|
High-Level Language Interface |
|
|
483 | (24) |
|
Why Program in Mixed Mode? |
|
|
484 | (1) |
|
|
|
484 | (2) |
|
Calling Assembly Procedures from C |
|
|
486 | (7) |
|
|
|
488 | (5) |
|
Calling C Functions from Assembly |
|
|
493 | (2) |
|
|
|
495 | (9) |
|
|
|
496 | (1) |
|
|
|
497 | (1) |
|
Extended Inline Statements |
|
|
498 | (2) |
|
|
|
500 | (4) |
|
|
|
504 | (1) |
|
|
|
504 | (1) |
|
|
|
504 | (3) |
|
Floating-Point Operations |
|
|
507 | (20) |
|
|
|
507 | (1) |
|
Floating-Point Unit Organization |
|
|
508 | (4) |
|
|
|
508 | (2) |
|
Control and Status Registers |
|
|
510 | (2) |
|
Floating-Point Instructions |
|
|
512 | (7) |
|
|
|
513 | (1) |
|
|
|
514 | (1) |
|
|
|
514 | (1) |
|
|
|
515 | (1) |
|
|
|
516 | (1) |
|
|
|
517 | (1) |
|
|
|
518 | (1) |
|
|
|
519 | (5) |
|
|
|
524 | (1) |
|
|
|
524 | (1) |
|
|
|
525 | (2) |
|
|
|
527 | (150) |
|
A Internal Data Representation |
|
|
529 | (38) |
|
A.1 Positional Number Systems |
|
|
529 | (2) |
|
|
|
531 | (1) |
|
A.2 Number Systems Conversion |
|
|
532 | (1) |
|
A.2.1 Conversion to Decimal |
|
|
532 | (2) |
|
A.2.2 Conversion from Decimal |
|
|
534 | (2) |
|
A.2.3 Conversion Among Binary, Octal, and Hexadecimal |
|
|
536 | (2) |
|
A.3 Unsigned Integer Representation |
|
|
538 | (1) |
|
A.3.1 Arithmetic on Unsigned Integers |
|
|
539 | (6) |
|
A.4 Signed Integer Representation |
|
|
545 | (1) |
|
A.4.1 Signed Magnitude Representation |
|
|
546 | (1) |
|
A.4.2 Excess-M Representation |
|
|
547 | (1) |
|
A.4.3 1's Complement Representation |
|
|
547 | (3) |
|
A.4.4 2's Complement Representation |
|
|
550 | (1) |
|
A.5 Floating-Point Representation |
|
|
551 | (1) |
|
|
|
552 | (3) |
|
A.5.2 Representing Floating-Point Numbers |
|
|
555 | (1) |
|
A.5.3 Floating-Point Representation |
|
|
556 | (4) |
|
A.5.4 Floating-Point Addition |
|
|
560 | (1) |
|
A.5.5 Floating-Point Multiplication |
|
|
561 | (1) |
|
A.6 Character Representation |
|
|
561 | (2) |
|
|
|
563 | (1) |
|
|
|
564 | (2) |
|
A.9 Programming Exercises |
|
|
566 | (1) |
|
|
|
567 | (16) |
|
|
|
567 | (1) |
|
B.2 Structure of Assembly Language Programs |
|
|
568 | (1) |
|
B.3 Input/Output Routines |
|
|
569 | (5) |
|
B.4 Assembling and Linking |
|
|
574 | (1) |
|
B.4.1 The Assembly Process |
|
|
574 | (7) |
|
B.4.2 Linking Object Files |
|
|
581 | (1) |
|
|
|
581 | (1) |
|
|
|
581 | (1) |
|
|
|
581 | (1) |
|
B.8 Programming Exercises |
|
|
582 | (1) |
|
C Debugging Assembly Language Programs |
|
|
583 | (22) |
|
C.1 Strategies to Debug Assembly Language Programs |
|
|
583 | (3) |
|
C.2 Preparing Your Program |
|
|
586 | (1) |
|
|
|
586 | (1) |
|
|
|
587 | (5) |
|
|
|
592 | (3) |
|
C.3.3 Miscellaneous Group |
|
|
595 | (1) |
|
|
|
595 | (2) |
|
C.4 Data Display Debugger |
|
|
597 | (5) |
|
|
|
602 | (1) |
|
|
|
603 | (1) |
|
|
|
603 | (1) |
|
C.8 Programming Exercises |
|
|
603 | (2) |
|
D SPIM Simulator and Debugger |
|
|
605 | (10) |
|
|
|
605 | (3) |
|
|
|
608 | (2) |
|
D.3 Running and Debugging a Program |
|
|
610 | (1) |
|
D.3.1 Loading and Running |
|
|
610 | (1) |
|
|
|
610 | (3) |
|
|
|
613 | (1) |
|
|
|
613 | (1) |
|
D.6 Programming Exercises |
|
|
613 | (2) |
|
|
|
615 | (36) |
|
|
|
615 | (1) |
|
E.1.1 Instruction Prefixes |
|
|
615 | (2) |
|
E.1.2 General Instruction Format |
|
|
617 | (1) |
|
E.2 Selected Instructions |
|
|
618 | (33) |
|
F MIPS/SPIM Instruction Set |
|
|
651 | (22) |
|
|
|
673 | (4) |
| Index |
|
677 | |