Table of Contents for
X86 Assembly Language and C Fundamentals
Close
Version ebook
/
Retour
X86 Assembly Language and C Fundamentals
by Joseph Cavanagh
Published by CRC Press, 2015
X86 Assembly Language and C Fundamentals
Preliminaries
By the same Author
X86 Assembly Language and C Fundamentals
X86 Assembly Language and C Fundamentals
Preface
Chapter 1 Number Systems and Number Representations
Chapter 2 X86 Processor Architecture
Chapter 3 Addressing Modes
Chapter 4 C Programming Fundamentals
Chapter 5 Data Transfer Instructions
Chapter 6 Branching and Looping Instructions
Chapter 7 Stack Operations
Chapter 8 Logical, Bit, Shift, and Rotate Instructions
Chapter 9 Fixed-Point Arithmetic Instructions
Chapter 10 Binary-Coded Decimal Arithmetic Instructions
Chapter 11 Floating-Point Arithmetic Instructions
Chapter 12 Procedures
Chapter 13 String Instructions
Chapter 14 Arrays
Chapter 15 Macros
Chapter 16 Interrupts and Input/Output Operations
Chapter 17 Additional Programming Examples
Appendix A ASCII Character Codes
Appendix B Answers to Select Problems
Prev
Previous Chapter
X86 Assembly Language and C Fundamentals
Next
Next Chapter
Preface
Preliminaries
By the same Author
Preface
Chapter 1
Number Systems and Number Representations
1.1 Number Systems
1.1.1 Binary Number System
1.1.2 Octal Number System
1.1.3 Decimal Number System
1.1.4 Hexadecimal Number System
1.1.5 Arithmetic Operations
1.1.6 Conversion between Radices
1.2 Number Representations
1.2.1 Sign Magnitude
1.2.2 Diminished-Radix Complement
1.2.3 Radix Complement
1.2.4 Arithmetic Operations
1.3 Problems
Figures
Figure 1.1
Figure 1.2
Figure 1.3
Figure 1.4
Figure 1.5
Figure 1.6
Figure 1.7
Figure 1.8
Figure 1.9
Figure 1.10
Figure 1.11
Figure 1.12
Figure 1.13
Figure 1.14
Figure 1.15
Figure 1.16
Figure 1.17
Figure 1.18
Figure 1.19
Figure 1.20
Figure 1.21
Figure 1.22
Figure 1.23
Figure 1.24
Tables
Table 1.1
Table 1.2
Table 1.3
Table 1.4
Table 1.5
Table 1.6
Table 1.7
Table 1.8
Table 1.9
Table 1.10
Table 1.11
Table 1.12
Table 1.13
Table 1.14
Chapter 2
X86 Processor Architecture
2.1 General Architecture
2.2 Arithmetic and Logic Unit
2.3 Control Unit
2.4 Memory Unit
2.4.1 Main Memory
2.4.2 Hamming Code
2.4.3 Cache Memory
2.5 Input/Output
2.5.1 Tape Drives
2.5.2 Disk Drives
2.6 Register Set
2.6.1 General-Purpose Registers
2.6.2 Segment Registers
2.6.3 EFLAGS Register
2.6.4 Instruction Pointer
2.6.5 Floating-Point Registers
2.7 Translation Lookaside Buffer
2.8 The Assembler
2.8.1 The Assembly Process
2.9 Problems
Figures
Figure 2.1
Figure 2.2
Figure 2.3
Figure 2.4
Figure 2.5
Figure 2.6
Figure 2.7
Figure 2.8
Figure 2.9
Figure 2.10
Figure 2.11
Figure 2.12
Figure 2.13
Figure 2.14
Figure 2.15
Figure 2.16
Figure 2.17
Figure 2.18
Figure 2.19
Figure 2.20
Figure 2.21
Figure 2.22
Figure 2.23
Figure 2.24
Figure 2.25
Figure 2.26
Figure 2.27
Figure 2.28
Tables
Table 2.1
Table 2.2
Chapter 3
Addressing Modes
3.1 Register Addressing
3.2 Immediate Addressing
3.3 Direct Memory Addressing
3.4 Base (Register Indirect) Memory Addressing
3.5 Base or Index Plus Displacement Addressing
3.6 Base and Index Plus Displacement Addressing
3.7 Scale Factor
3.8 Segment Override Prefix
3.9 X86 Operation Modes
3.9.1 Protected Mode
3.9.2 Real Mode
3.10 Problems
Figures
Figure 3.1
Figure 3.2
Figure 3.3
Figure 3.4
Figure 3.5
Figure 3.6
Chapter 4
C Programming Fundamentals
4.1 Structure of a C Program
4.2 Variables and Constants
4.2.1 Variables
4.2.2 Constants
4.3 Input and Output
4.3.1 Printf () Function
4.3.2 Scanf () Function
4.4 Operators
4.4.1 Arithmetic Operators
4.4.2 Relational Operators
4.4.3 The If Statement
4.4.4 The Else Statement
4.4.5 Logical Operators
4.4.6 Conditional Operator
4.4.7 Increment and Decrement Operators
4.4.8 Bitwise Operators
4.5 While Loop
4.6 For Loop
4.7 Additional C Constructs
4.7.1 Arrays
4.7.2 Strings
4.7.3 Pointers
4.7.4 Functions
4.8 Problems
Figures
Figure 4.1
Figure 4.2
Figure 4.3
Figure 4.4
Figure 4.5
Figure 4.6
Figure 4.7
Figure 4.8
Figure 4.9
Figure 4.10
Figure 4.11
Figure 4.12
Figure 4.13
Figure 4.14
Figure 4.15
Figure 4.16
Figure 4.17
Figure 4.18
Figure 4.19
Figure 4.20
Figure 4.21
Figure 4.22
Figure 4.23
Figure 4.24
Figure 4.25
Figure 4.26
Figure 4.27
Figure 4.28
Figure 4.29
Figure 4.30
Figure 4.31
Figure 4.32
Figure 4.33
Figure 4.34
Figure 4.35
Figure 4.36
Figure 4.37
Figure 4.38
Figure 4.39
Figure 4.40
Figure 4.41
Figure 4.42
Figure 4.43
Figure 4.44
Figure 4.45
Figure 4.46
Figure 4.47
Figure 4.48
Figure 4.49
Figure 4.50
Figure 4.51
Figure 4.52
Figure 4.53
Figure 4.54
Figure 4.55
Figure 4.56
Tables
Table 4.1
Table 4.2
Table 4.3
Table 4.4
Table 4.5
Table 4.6
Table 4.7
Table 4.8
Table 4.9
Table 4.10
Table 4.11
Table 4.12
Table 4.13
Table 4.14
Chapter 5
Data Transfer Instructions
5.1 Data Types
5.1.1 Signed Binary Integers
5.1.2 Unsigned Binary Integers
5.1.3 Unpacked and Packed BCD Integers
5.1.4 Floating-Point Numbers
5.2 Move Instructions
5.2.1 General Move Instructions
5.2.2 Move with Sign/Zero Extension
5.2.3 Conditional Move
5.3 Load Effective Address
5.4 Load Segment Registers
5.5 Exchange Instructions
5.5.1 Exchange
5.5.2 Byte Swap
5.5.3 Exchange and Add
5.5.4 Compare and Exchange
5.6 Translate
5.7 Conversion Instructions
5.8 Problems
Figures
Figure 5.1
Figure 5.2
Figure 5.3
Figure 5.4
Figure 5.5
Figure 5.6
Figure 5.7
Figure 5.8
Figure 5.9
Figure 5.10
Figure 5.11
Figure 5.12
Figure 5.13
Figure 5.14
Figure 5.15
Figure 5.16
Figure 5.17
Figure 5.18
Figure 5.19
Figure 5.20
Figure 5.21
Figure 5.22
Figure 5.23
Tables
Table 5.1
Table 5.2
Table 5.3
Table 5.4
Chapter 6
Branching and Looping Instructions
6.1 Branching Instructions
6.1.1 Unconditional Jump Instruction
6.1.2 Compare Instruction
6.1.3 Conditional Jump Instructions
6.2 Looping Instructions
6.2.1 Unconditional Loop
6.2.2 Conditional Loops
6.2.3 Implementing
while
Loops
6.2.4 Implementing
for
Loops
6.3 Problems
Figures
Figure 6.1
Figure 6.2
Figure 6.3
Figure 6.4
Figure 6.5
Figure 6.6
Figure 6.7
Figure 6.8
Figure 6.9
Figure 6.10
Figure 6.11
Figure 6.12
Tables
Table 6.1
Table 6.2
Table 6.3
Table 6.4
Table 6.5
Table 6.6
Chapter 7
Stack Operations
7.1 Stack Structure
7.2 Additional Push Instructions
7.3 Additional Pop Instructions
7.4 Problems
Figures
Figure 7.1
Figure 7.2
Figure 7.3
Figure 7.4
Chapter 8
Logical, Bit, Shift, and Rotate Instructions
8.1 Logical AND Instruction
8.2 Logical Inclusive-OR Instruction
8.3 Logical Exclusive-OR Instruction
8.4 Logical NOT Instruction — 1s Complement
8.5 NEG Instruction — 2s Complement
8.6 TEST and Set Byte on Condition Instructions
8.6.1 TEST Instruction
8.6.2 Set Byte on Condition (SETcc) Instruction
8.7 Bit Test Instructions
8.7.1 Bit Test (BT) Instruction
8.7.2 Bit Test and Set (BTS) Instruction
8.7.3 Bit Test and Reset (BTR) Instruction
8.7.4 Bit Test and Complement (BTC) Instruction
8.8 Bit Scan Instructions
8.8.1 Bit Scan Forward (BSF) Instruction
8.8.2 Bit Scan Reverse (BSR) Instruction
8.9 Shift Instructions
8.9.1 Shift Arithmetic Left (SAL) Instruction
8.9.2 Shift Logical Left (SHL) Instruction
8.9.3 Shift Arithmetic Right (SAR) Instruction
8.9.4 Shift Logical Right (SHR) Instruction
8.9.5 Shift Left Double (SHLD) Instruction
8.9.6 Shift Right Double (SHRD) Instruction
8.10 Rotate Instructions
8.10.1 Rotate Left (ROL) Instruction
8.10.2 Rotate through Carry Left (RCL) Instruction
8.10.3 Rotate Right (ROR) Instruction
8.10.4 Rotate through Carry Right (RCR) Instruction
8.11 Problems
Figures
Figure 8.1
Figure 8.2
Figure 8.3
Figure 8.4
Figure 8.5
Figure 8.6
Figure 8.7
Figure 8.8
Figure 8.9
Figure 8.10
Figure 8.11
Figure 8.12
Figure 8.13
Figure 8.14
Figure 8.15
Figure 8.16
Figure 8.17
Figure 8.18
Figure 8.19
Figure 8.20
Figure 8.21
Figure 8.22
Figure 8.23
Figure 8.24
Figure 8.25
Figure 8.26
Figure 8.27
Figure 8.28
Figure 8.29
Figure 8.30
Figure 8.31
Figure 8.32
Tables
Table 8.1
Table 8.2
Table 8.3
Table 8.4
Table 8.5
Table 8.6
Table 8.7
Chapter 9
Fixed-Point Arithmetic Instructions
9.1 Addition
9.1.1 Add (ADD) Instruction
9.1.2 Add with Carry (ADC) Instruction
9.1.3 Increment by 1 (INC) Instruction
9.2 Subtraction
9.2.1 Subtract (SUB) Instruction
9.2.2 Integer Subtraction with Borrow (SBB) Instruction
9.2.3 Decrement by 1 (DEC) Instruction
9.2.4 Two's Complement Negation (NEG) Instruction
9.3 Multiplication
9.3.1 Unsigned Multiply (MUL) Instruction
9.3.2 Signed Multiply (IMUL) Instruction
9.4 Division
9.4.1 Unsigned Divide (DIV) Instruction
9.4.2 Signed Divide (IDIV) Instruction
9.5 Problems
Figures
Figure 9.1
Figure 9.2
Figure 9.3
Figure 9.4
Figure 9.5
Figure 9.6
Figure 9.7
Figure 9.8
Figure 9.9
Figure 9.10
Figure 9.11
Figure 9.12
Figure 9.13
Figure 9.14
Figure 9.15
Figure 9.16
Figure 9.17
Figure 9.18
Figure 9.19
Figure 9.20
Figure 9.21
Figure 9.22
Figure 9.23
Figure 9.24
Figure 9.25
Figure 9.26
Figure 9.27
Figure 9.28
Tables
Table 9.1
Table 9.2
Table 9.3
Chapter 10
Binary-Coded Decimal Arithmetic Instructions
10.1 ASCII Adjust After Addition (AAA) Instruction
10.2 Decimal Adjust AL after Addition (DAA) Instruction
10.3 ASCII Adjust AL after Subtraction (AAS) Instruction
10.4 Decimal Adjust AL after Subtraction (DAS) Instruction
10.5 ASCII Adjust AX after Multiplication (AAM) Instruction
10.6 ASCII Adjust AX before Division (AAD) Instruction
10.7 Problems
Figures
Figure 10.1
Figure 10.2
Figure 10.3
Figure 10.4
Figure 10.5
Figure 10.6
Figure 10.7
Figure 10.8
Figure 10.9
Figure 10.10
Figure 10.11
Figure 10.12
Figure 10.13
Figure 10.14
Figure 10.15
Figure 10.16
Tables
Table 10.1
Chapter 11
Floating-Point Arithmetic Instructions
11.1 Floating-Point Fundamentals
11.1.1 Rounding Methods
11.2 Load Data Instructions
11.2.1 Load Floating-Point Value (FLD) Instruction
11.2.2 Load Constant Instructions
11.2.3 Load X87 FPU Control Word (FLDCW) Instruction
11.2.4 Load X87 FPU Environment (FLDENV) Instruction
11.2.5 Load Integer (FILD) Instruction
11.2.6 Load Binary-Coded Decimal (FBLD) Instruction
11.3 Store Data Instructions
11.3.1 Store BCD Integer and Pop (FBSTP) Instruction
11.3.2 Store Integer (FIST) Instruction
11.3.3 Store Integer and Pop (FISTP) Instruction
11.3.4 Store Integer with Truncation and Pop (FISTTP) Instruction
11.3.5 Store Floating-Point Value (FST) Instruction
11.3.6 Store Floating-Point Value and Pop (FSTP) Instruction
11.3.7 Store X87 FPU Control Word (FSTCW) Instruction
11.3.8 Store X87 FPU Environment (FSTENV) Instruction
11.3.9 Store X87 FPU Status Word (FSTSW) Instruction
11.4 Addition Instructions
11.4.1 Overflow and Underflow
11.4.2 Add Instructions
11.5 Subtraction Instructions
11.5.1 Numerical Examples
11.5.2 Subtract Instructions
11.6 Multiplication Instructions
11.6.1 Double Bias
11.6.2 Numerical Examples
11.6.3 Multiply Instructions
11.7 Division Instructions
11.7.1 Zero Bias
11.7.2 Numerical Example
11.7.3 Divide Instructions
11.8 Compare Instructions
11.8.1 Compare Floating-Point Values
11.8.2 Compare Floating-Point Values and Set EFLAGS
11.8.3 Compare Integer
11.8.4 Test
11.8.5 Unordered Compare Floating-Point Values
11.9 Trigonometric Instructions
11.9.1 Cosine
11.9.2 Partial Arctangent
11.9.3 Partial Tangent
11.9.4 Sine
11.9.5 Sine and Cosine
11.10 Additional Instructions
11.10.1 Absolute Value
11.10.2 Change Sign
11.10.3 Decrement Stack-Top Pointer
11.10.4 Free Floating-Point Register
11.10.5 Increment Stack-Top Pointer
11.10.6 Partial Remainder
11.10.7 Round to Integer
11.10.8 Square Root
11.10.9 Exchange Register Contents
11.11 Problems
Figures
Figure 11.1
Figure 11.2
Figure 11.3
Figure 11.4
Figure 11.5
Figure 11.6
Figure 11.7
Figure 11.8
Figure 11.9
Figure 11.10
Figure 11.11
Figure 11.12
Figure 11.13
Figure 11.14
Figure 11.15
Figure 11.16
Figure 11.17
Figure 11.18
Figure 11.19
Figure 11.20
Figure 11.21
Figure 11.22
Figure 11.23
Figure 11.24
Figure 11.25
Figure 11.26
Figure 11.27
Figure 11.28
Figure 11.29
Figure 11.30
Figure 11.31
Figure 11.32
Figure 11.33
Figure 11.34
Figure 11.35
Figure 11.36
Figure 11.37
Figure 11.38
Tables
Table 11.1
Table 11.2
Table 11.3
Chapter 12
Procedures
12.1 Call a Procedure
12.2 Return from a Procedure
12.3 Passing Parameters to a Procedure
12.4 Problems
Figures
Figure 12.1
Figure 12.2
Figure 12.3
Figure 12.4
Figure 12.5
Figure 12.6
Figure 12.7
Figure 12.8
Chapter 13
String Instructions
13.1 Repeat Prefixes
13.1.1 REP Prefix
13.1.2 REPE / REPZ Prefix
13.1.3 REPNE / REPNZ Prefix
13.2 Move String Instructions
13.2.1 Move Data from String to String (Explicit Operands) Instructions
13.2.2 Move Data from String to String (No Operands) Instructions
13.3 Load String Instructions
13.3.1 Load String (Explicit Operands) Instructions
13.3.2 Load String (No Operands) Instructions
13.4 Store String Instructions
13.4.1 Store String (Explicit Operands) Instructions
13.4.2 Store String (No Operands) Instructions
13.5 Compare Strings Instructions
13.5.1 Compare Strings (Explicit Operands) Instructions
13.5.2 Compare Strings (No Operands) Instructions
13.6 Scan String Instructions
13.6.1 Scan String (Explicit Operands) Instructions
13.6.2 Scan String (No Operands) Instructions
13.7 Problems
Figures
Figure 13.1
Figure 13.2
Figure 13.3
Figure 13.4
Figure 13.5
Figure 13.6
Figure 13.7
Figure 13.8
Figure 13.9
Figure 13.10
Chapter 14
Arrays
14.1 One-Dimensional Arrays
14.1.1 One-Dimensional Arrays in C
14.2 Multidimensional Arrays
14.3 Problems
Figures
Figure 14.1
Figure 14.2
Figure 14.3
Figure 14.4
Figure 14.5
Figure 14.6
Figure 14.7
Figure 14.8
Figure 14.9
Figure 14.10
Chapter 15
Macros
15.1 Macro Definitions
15.2 Macro Examples
15.3 Problems
Figures
Figure 15.1
Figure 15.2
Figure 15.3
Figure 15.4
Figure 15.5
Figure 15.6
Figure 15.7
Figure 15.8
Figure 15.9
Figure 15.10
Figure 15.11
Figure 15.12
Figure 15.13
Tables
Table 15.1
Chapter 16
Interrupts and Input/Output Operations
16.1 Interrupts
16.2 Direct Memory Access
16.3 Memory-Mapped I/O
16.4 In/Out Instructions
16.4.1 Register I/O IN Instructions
16.4.2 Register I/O OUT Instructions
16.4.3 String I/O IN Instructions
16.4.4 String I/O OUT Instructions
16.5 Problems
Figures
Figure 16.1
Figure 16.2
Figure 16.3
Chapter 17
Additional Programming Examples
17.1 Programming Examples
17.2 Problems
Figures
Figure 17.1
Figure 17.2
Figure 17.3
Figure 17.4
Figure 17.5
Figure 17.6
Figure 17.7
Figure 17.8
Figure 17.9
Figure 17.10
Figure 17.11
Figure 17.12
Figure 17.13
Figure 17.14
Figure 17.15
Figure 17.16
Figure 17.17
Figure 17.18
Figure 17.19
Figure 17.20
Figure 17.21
Figure 17.22
Figure 17.23
Figure 17.24
Figure 17.25
Figure 17.26
Appendix A
ASCII Character Codes
Appendix B
Answers to Select Problems
Chapter 1 Number Systems and Number Representations
Chapter 2 X86 Processor Architecture
Chapter 3 Addressing Modes
Chapter 4 C Programming Fundamentals
Chapter 5 Data Transfer Instructions
Chapter 6 Branching and Looping Instructions
Chapter 7 Stack Operations
Chapter 8 Logical, Bit, Shift, and Rotate Instructions
Chapter 9 Fixed-Point Arithmetic Instructions
Chapter 10 Binary-Coded Decimal Arithmetic Instructions
Chapter 11 Floating-Point Arithmetic Instructions
Chapter 12 Procedures
Chapter 13 String Instructions
Chapter 14 Arrays
Chapter 15 Macros
Chapter 16 Interrupts and Input/Output Operations
Chapter 17 Additional Programming Examples
Prev
Previous Chapter
X86 Assembly Language and C Fundamentals
Next
Next Chapter
Preface