This is not the current version of the class.

Assembly 2: Calling convention and control flow


We discuss calling conventions and control flow in machine code.

Full lecture notes on assemblyTextbook readings

Calling convention

Elements of a calling convention

Let’s explore:


Return values

Function entry and exit sequence

Action of call FUNCTION instruction

subq $8, %rsp
movq %NEXT_rip, (%rsp)
movq FUNCTION, %rip

Action of ret instruction

addq $8, %rsp
movq -8(%rsp), %rip

Local variables