Introduction to 64 Bit Intel Assembly Language Programming for Linux

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Author(s): Ray Seyfarth

Language: English

Introduction to 64 Bit Intel Assembly Language Programming for Linux
Preface
Acknowledgements
Contents
Chapter 1: Introduction
1.1 Why study assembly language?
1.2 What is a computer?
1.2.1 Bytes
1.2.2 Program execution
1.3 Machine language
1.4 Assembly language
1.5 Assembling and linking
Chapter 2: Numbers
2.1 Binary numbers
2.2 Hexadecimal numbers
2.3 Integers
2.3.1 Binary addition
2.3.2 Binary multiplication
2.4 Floating point numbers
2.4.1 Converting decimal numbers to floats
2.4.2 Converting floats to decimal
2.4.3 Floating point addition
2.4.4 Floating point multiplication
Chapter 3: Computer memory
3.1 Memory mapping
3.2 Process memory model in Linux
3.3 Memory example
3.4 Examining memory with gdb
3.4.1 Printing with gdb
3.4.2 Examining memory
Chapter 4: Memory mapping in 64 bit mode
4.1 The memory mapping register
4.2 Page Map Level 4
4.3 Page Directory Pointer Table
4.4 Page Directory Table
4.5 Page Table
4.6 Large pages
4.7 CPU Support for Fast Lookups
Chapter 5: Registers
5.1 Moving a constant into a register
5.2 Moving values from memory into registers
5.3 Moving values from a register into memory
5.4 Moving data from one register to another
Chapter 6: A little bit of math
6.1 Negation
6.2 Addition
6.3 Subtraction
6.4 Multiplication
6.5 Division
6.6 Conditional move instructions
6.7 Why move to a register?
Chapter 7: Bit operations
7.1 Not operation
7.2 And operation
7.3 Or operation
7.4 Exclusive or operation
7.5 Shift operations
7.6 Bit testing and setting
7.7 Extracting and filling a bit field
Chapter 8: Branching and looping
8.1 Unconditional jump
8.2 Conditional jump
8.2.1 Simple if statement
8.2.2 If/else statement
8.2.3 If/else-if/else statement
8.3 Looping with conditional jumps
8.3.1 While loops
8.3.2 Do-while loops
8.3.3 Counting loops
8.4 Loop instructions
8.5 Repeat string (array) instructions
8.5.1 String instructions
Chapter 9: Functions
9.1 The stack
9.2 Call instruction
9.3 Return instruction
9.4 Function parameters and return value
9.5 Stack frames
9.6 Recursion
Chapter 10: Arrays
10.1 Array address computation
10.2 General pattern for memory references
10.3 Allocating arrays
10.4 Processing arrays
10.4.1 Creating the array
10.4.2 Filling the array with random numbers
10.4.3 Printing the array
10.4.4 Finding the minimum value
10.4.5 Main program for the array minimum
10.5 Command line parameter array
Chapter 11: Floating point instructions
11.1 Floating point registers
11.2 Moving data to/from floating point registers
11.2.1 Moving scalars
11.2.2 Moving packed data
11.3 Addition
11.4 Subtraction
11.5 Multiplication and division
11.6 Conversion
11.6.1 Converting to a different length floating point
11.6.2 Converting floating point to/from integer
11.7 Floating point comparison
11.8 Mathematical functions
11.8.1 Minimum and maximum
11.8.2 Rounding
11.8.3 Square roots
11.9 Sample code
11.9.1 Distance in 3D
11.9.2 Dot product of 3D vectors
11.9.3 Polynomial evaluation
Chapter 12: System calls
12.1 32 bit system calls
12.2 64 bit system calls
12.3 C wrapper functions
12.3.1 open system call
12.3.2 read and write system calls
12.3.3 lseek system call
12.3.4 close system call
Chapter 13: Structs
13.1 Symbolic names for offsets
13.2 Allocating and using an array of structs
Chapter 14: Using the C stream I/0 functions
14.1 Opening a file
14.2 fscanf and fprintf
14.3 fgetc and fputc
14.4 fgets and fputs
14.5 fread and fwrite
14.6 fseek and ftell
14.7 fclose
Chapter 15: Data structures
15.1 Linked lists
15.1.1 List node structure
15.1.2 Creating an empty list
15.1.3 Inserting a number into a list
15.1.4 Traversing the list
15.2 Doubly-linked lists
15.2.1 Doubly-linked list node structure
15.2.2 Creating a new list
15.2.3 Inserting at the front of the list
15.2.4 List traversal
15.3 Hash tables
15.3.1 A good hash function for integers
15.3.2 A good hash function for strings
15.3.3 Hash table node structure and array
15.3.4 Function to find a value in the hash table
15.3.5 Insertion code
15.3.6 Printing the hash table
15.3.7 Testing the hash table
15.4 Binary trees
15.4.1 Binary tree node and tree structures
15.4.2 Creating an empty tree
15.4.3 Finding a key in a tree
15.4.4 Inserting a key into the tree
15.4.5 Printing the keys in order
Chapter 16: High performance assembly programming
16.1 General optimization strategies
16.2 Use a better algorithm
16.3 Use C or C++
16.4 Efficient use of cache
16.5 Common subexpression elimination
16.6 Strength reduction
16.7 Use registers efficiently
16.8 Use fewer branches
16.9 Convert loops to branch at the bottom
16.10 Unroll loops
16.11 Merge loops
16.12 Split loops
16.13 Interchange loops
16.14 Move loop invariant code outside loops
16.15 Remove recursion
16.16 Eliminate stack frames
16.17 Inline functions
16.18 Reduce dependencies to allow super-scalar execution
16.19 Use specialized instructions
Chapter 17: Counting bits in an array
17.1 C function
17.2 Counting 1 bits in assembly
17.3 Precomputing the number of bits in each byte
17.4 Using the popcnt instruction
Chapter 18: Sobel filter
18.1 Sobel in C
18.2 Sobel computed using SSE instructions
Chapter 19: Computing Correlation
19.1 C implementation
19.2 Implementation using SSE instructions
19.3 Implementation using AVX instructions
Appendix A: Using gdb
A.1 Preparing for gdb
A.2 Starting
A.3 Quitting
A.4 Setting break points
A.5 Running
A.6 Printing a trace of stack frames
A.7 Examining registers
A.8 Examining memory
Appendix B: Using scanf and printf
B.1 scanf
B.2 printf
Appendix C: Using macros in yasm
C.1 Single line macros
C.2 Multi-line macros
C.3 Preprocessor variables
Appendix D: Sources for more information
D.1 yasm user manual
D.2 nasm user manual
D.3 Dr. Paul Carter's free assembly book
D.4 64 bit Machine Level Programming
D.5 GDB Manual
D.6 DDD Manual
D.7 Intel Documentation
Index