Using registers as local variables in a leaf function

  • Local variable:

      • is a variable that is "created" (= reserved) when the function starts running

      • The local variable is "destroyed" (= unreserved) when the function exits (= returns)

  • Safety pre-condition:

      • Only leaf functions can designate (= reserve) available (= unused) registers as its local variables

    (Non-leaf function cannot use registers as its local variables because when it calls another function, that function can overwrite values in registers used as local variables

    I.e.: reserving registers in a non-leaf function is not possible)