Machine-Level Programming
# Machine-Level Programming
# Basic
# Intel x86 Processors
Complex instruction set computer (CISC)
RISC
IA32
x86-64
ARM
# Assembly/Machine Code View
PC: Program counter
gcc -Og -S sum.c
# Registers
%rsp
stack
# Moving Data
# Control
# Condition codes
# Conditional branches
# Loop
- For-While Conversion
# Switch Statements
# Procedures
- ABI(二进制程序接口)
- Stack
- Grows toward lower address
%rsp
- address of "top" element
- Passing control
- Passing data
- Managing local data
- Stack Frame
%rbp
Frame Pointer
- Register Saving Conventions
- Caller Saved
- Callee Saved
# Data
- Array
- one dimensional
- multi dimensional
- Structures
- Alignment
- only for base data
- Alignment
- Floating Point
- SSE
- SIMD
# Advanced Topics
- Memory Layout
x86-64 Linux Memory Layout
- Buffer Overflow
- Unions
编辑 (opens new window)