1/11
Looks like no tags are added yet.
What is the Program Counter initialized to? What is it aka? What does it hold after first instruction?
Address of first instruction
PC = %eip
Address of next instruction
What is the Instruction Set Architecture (ISA / instruction API)?
Set of instructions provided by machine to allow translation of source code
What are the 3 main parts of a CPU and their subcomponents?
Control Unit:
Instruction register (current instruction)
Instruction counter (pointer of next instruction — auto increments)
Status register (flags (stores) info from last operation)
Decoder (“reads” instruction and decides signal to generate)
Signal generator (communicates with rest of processor)
Execution Unit:
Arithmetic Logic Unit (ALU — calculates)
Registers (very fast memory for operands)
Memory:
Stores data and program instructions (accessed by address)
What are the stages of execution?
Fetch → Decode → Get data → Execute → Write data
What assembly code commonly at beginning and end of a function?
push and ret
Which register used to return a value from a function?
%eax
When allocating an int array on the stack for 64 bytes, how do you reach array[7] from %ebp which was where %esp was before the allocation?
Beginning of array at -64 and want 7×4 = 28th byte so -64 + 28 = -36(%ebp)
How is %eax split up in terms of bytes?
eax = 8 bytes
ax = rightmost 4
ah = left 2 of ax
al = right 2 of ax
Which registers are caller save? Callee?
a d c = caller
bx si di = callee
How many values can be represented with n bits? What is the max value unsigned?
2n
2n-1
What does the call function do?
Push return address (%ebp) onto stack and subtracts as much as needed from %esp (it doesn’t literally do this but every function has to so technically)
How do you convert from base 10 to any base fast way?
Divide by the base, record the quotient and remainder
Repeat with the quotient and record the remainders going down
Read the remainders bottom up and that’s the number in that base