Basic
- History of Intel processors and architectures
- C, assembly, machine code
- Assembly Basics: Registers, operands, move
- Arithmetic & logical operations
Intel x86 Processors
- Dominate laptop/desktop/server market
- Evolutionary design
- Complex instruction set computer (CISC)
Definitions
- Architecture: The parts of a processor design that one needs to
understand or write assembly/machine code - Microarchitecture: Implementation of the architecture
- Code Forms: Machine Code, Assembly Code
Assembly/Machine Code View
Programmer-Visible State
PC, Register file, Condition codes, Memory
Turning C into Object Code
C program --Complier–> Asm program --Assembler–> Object program–Linker–> Executable program
Assembly Characteristics
- Data Types
- Integer
- Floating point data of 4, 8, or 10 bytes
- Code: Byte sequences encoding series of instructions
- No aggregate types such as arrays or structures
- Operations
- Perform arithmetic function on register or memory data
- Transfer data between memory and register
- Transfer control
x86-64 Integer Registers
16 registers: hold integers and pointers
%r: 64 bit %e: 32bit
%rax %rcx %rdx %rbx %rsi %rdi %rsp %rbp
%r8-15
Moving Data
- Moving Data
- movq Source, Dest;
- Operand Types
- Immediate: Constant integer data
- Register: One of 16 integer registers
- Memory: 8 consecutive bytes of memory at address given by register
Simple Memory Addressing Modes
-
Normal (R)
- Register R specifies memory address
- movq (%rcx), %rax
-
Displacement
- Register R specifies start of memory region
- movq 8(%rbp), %rdx
Complete Memory Addressing Modes
- Most General Form
- D(Rb, Ri, S)
- Special Cases
- (Rb, Ri)
- D(Rb, Ri)
- (Rb, Ri, S)
Address Computation Instruction
- leaq Src, Dst
- Src is address mode expression
- Set Dst to address denoted by expression
- Uses
- Computing addresses without a memory reference
- Computing arithmetic expressions of the form x + k*y
Some Arithmetic Operations
- Two Operand Instructions
- One Operand Instructions