Project 3 posted
General structure:
Loop: while(<condition>) { <loop body> }
Assembly conversion:
.LOOP: cmpX
jXX .END
<asm loop body>
jmp .LOOP
.END:
<asm following code>
General structure:
If statement: if(<condition>) { <if body> }
Assembly conversion:
cmpX
jXX .AFTER
<asm if body>
.AFTER:
<asm following code>
Generalizations not always accurately translate to assembly.
Compilers may perform optimizations causing unexpected behavior.
Procedures are defined as blocks of code with arguments and return values.
Caller: procedure making the call.
Callee: procedure being called.
Control flow managed via the instruction pointer %rip
.
Passing data involves arguments through registers and returning values.
Local variables reside in the stack frame, which is allocated during the call.
Call: - Push return address onto stack.
Jump to the callee address.
Return: - Restore return address from the stack.
Data passed via registers.
If > 6 args, push onto caller's stack frame for callee retrieval.
Return values in %rax
.
Stored in registers, handled via callee-saved and caller-saved conventions.
Callee saves register values onto the stack before use if the registers are in use.
Comparisons made using control flow in recursive examples.
Real scenarios require thorough understanding of stack and frame allocations.