Machine Programming Procedures

References

Outline

Mechanisms in Procedures

Mechanisms in Procedures (continued)

x86-64 Stack

x86-64 Stack: Push

x86-64 Stack: Pop

x86-64 Stack Example

x86-64 Stack
x86-64 Stack

Code Examples

Code Examples

Procedure Control Flow

Procedure Control Flow Example

x86-64 Procedure Control Flow
x86-64 Procedure Control Flow

Procedure Data Flow

Stack-Based Languages

Stack-Based Languages (continued)

Call Chain Example

  • f: calls g

  • g: calls h twice

  • h: recursive
Call Chain
Call Chain

Stack Frames

x86-64/Linux Stack Frame

x86-64/Linux Stack Frame

x86-64 Linux Stack Frame
x86-64 Linux Stack Frame

Example: incr

Register Saving Conventions

x86-64 Linux Register Usage

x86-64 Linux Register Usage

Recursive Function Example

Recursive Function Example

Observations About Recursion

x86-64 Procedure Summary