comparison: mixed sign/unsigned -> cast all to unsigned Endian = little
infinity: exp = all 1s and frac = all 0s Nan: exp = all 1s and frac != all 0s
%cr3
: control register, store address of page table in physical memory
%r10, %r11
: caller-saved but not argument
condition codes: set by cmpq
, testq
, jne
(not equal / not zero)
- CF
: Carry Flag (for unsigned)
- ZF
: Zero Flag
- SF
: Sign Flag (for signed)
- OF
: Overflow Flag (for signed)
ja
(unsigned) may be optimized to do if (x > 6 || x < 0)
when x is signed.
cmov
: val = Test ? Then_Expr : Else_Expr
when safe (calculate both result. don't risk deference, side effects, expensive calculation)
test
: logical AND
cmp
: subtraction
immediate (constant integer): $0x400
, $-533
pushq [src]
(7th argument is at %rsp
): sub 0x08, %rsp
, mov [src], (%rsp)
call [label]
: push %rip
, jmp [label]
ret
: pop %rip
Stack: run-time. 8MB limit Heap: malloc()
SRAM: refresh in spacial locality (so memory access with spacial locality is good)
Cold (compulsory) miss: empty
Capacity miss: when working set is larger than the cache (no enough cache space to store all needed data for a program, cache is full and your data is not here)
Conflict miss: when multiple objects all map to the same level k block (hash collision: block i
at Lk+1
must be placed in block i mod 4
at Lk
, referencing blocks 0, 8, 0, 8,...
will miss every time)
Write-back + Write-allocate + Copy-on-Write (Anonymous file)
Address Example: 9+9+9+9+12=48 virtual address, 40+12=52 physical address, 4KB page size (2^12 byte page table, 8 byte payload per entry, 2^9 entries)
VPO = PPO = log_2(\text{page size}) because a level of page table only stores PPN (assume PPO are zeros, therefore force table to be page-size-aligned) and some extra bits
log_2(\frac{\text{page size}}{\text{8 byte payload}}) * n + \text{VPO} = \text{Virtual Address}
Symbol Table: store symbol definition
content: name, size, location of symbol
types of symbol, global variable name, function name (include main and library header) (maybe custom type and struct?)
does not contain built-in type
.data: initialized global, static variable, string constant .text: Code, Libraries .bss: uninitialized globals (only header) .symtab: procedure, static variable name
Relocatable Object File (.o): can be combined with other relocatable file, from a .c file
Executable Object File (a.out): linking (.o .a .so), link library at last cmd
Shared Object File (.so): linked dynamically
Static Libraries (.a archive files): created by achiever with (.o)
dlopen()
: link at run-time
Global Symbols: non-static function, non-static global variable
External Symbols: global symbols that are referenced but not defined by current module (printf
)
Local Symbols: only referenced in current module (static function, static variables either in function or global)
Not in symbol table: local variable in function, arguments, (maybe string) static variable: exist in life time of program, but accessible only in scope
Strong Symbol: procedures and initialized globals
Weak Symbol: uninitialized globals, or declared with extern
(has to be resolved).
Linking Rules
TODO: union in lecture 008 TODO: look at piazza
Table of Content