The Runtime Environment CSE 340 Principles of Programming




























































































![#include <stdio. h> int i; int a[10]; void inc(int x) { i++; x++; } #include <stdio. h> int i; int a[10]; void inc(int x) { i++; x++; }](https://slidetodoc.com/presentation_image_h/7ef0bad9e21a177f0ce09bafe0468882/image-93.jpg)


![[adamd@ragnuk]$ gcc –Wall pass_by_name_simulation. c [adamd@ragnuk]$. /a. out 5 #include <stdio. h> int i; [adamd@ragnuk]$ gcc –Wall pass_by_name_simulation. c [adamd@ragnuk]$. /a. out 5 #include <stdio. h> int i;](https://slidetodoc.com/presentation_image_h/7ef0bad9e21a177f0ce09bafe0468882/image-96.jpg)

















- Slides: 113
The Runtime Environment CSE 340 – Principles of Programming Languages Spring 2016 Adam Doupé Arizona State University http: //adamdoupe. com
Locations and Names • What is the semantic distinction between locations and names? • How does the compiler actually implement locations and names? – How does the compiler map names to memory locations? • We are going to look into this process – Assuming static scoping Adam Doupé, Principles of Programming Languages 2
Global Variables • Where can the compiler put variables? – Memory – Registers – Disk – "Cloud" • What are the constraints on those variables? – Who can access them? – Who can't? Adam Doupé, Principles of Programming Languages 3
int a; int b; float c; int main() { a = 10; b = 100; c = 10. 45; a = a + b; return 0; } a @ A b @ B c @ C mem[A] mem[B] mem[C] mem[A] mem[B] a @ 0 x 8049634 b @ 0 x 8049638 c @ 0 x 804963 c = 100 = 10. 45 = + Adam Doupé, Principles of Programming Languages movl $0 xa, 0 x 8049634 movl $0 x 64, 0 x 8049638 mov $0 x 41273333, %eax mov %eax, 0 x 804963 c mov 0 x 8049634, %edx mov 0 x 8049638, %eax lea (%edx, %eax, 1), %eax mov %eax, 0 x 8049634 4
Local Variables • What are the constraints on local variables? • Where can the compiler place local variables? – Global Memory (one for each function) Adam Doupé, Principles of Programming Languages 5
int fact(int n) { if (n == 0) { return 1; } else { return fact(n-1) * n; } } Adam Doupé, Principles of Programming Languages 6
Local Variables • What are the constraints on local variables? • Where can the compiler place local variables? – Global Memory (one for each function) – "Scratch memory" for each function Adam Doupé, Principles of Programming Languages 7
The Stack • Stack is essentially scratch memory for functions – Used in MIPS, ARM, x 86, and x 86 -64 processors • Starts at high memory addresses, and grows down • Functions are free to push registers or values onto the stack, or pop values from the stack into registers • The assembly language supports this on x 86 – %esp holds the address of the top of the stack – push %eax decrements the stack pointer (%esp) then stores the value in %eax to the location pointed to by the stack pointer – pop %eax stores the value at the location pointed to by the stack pointer into %eax, then increments the stack pointer (%esp) Adam Doupé, Principles of Programming Languages 8
Stack Example 0 x. FFFF … push %eax pop %ebx 0 x 10000 … Garbage 0 x 0000 %eax 0 xa %ebx 0 x 0 %esp 0 x 10000 Adam Doupé, Principles of Programming Languages 10
Stack Example 0 x. FFFF … push %eax pop %ebx 0 x 10000 … Garbage 0 x 0000 %eax 0 xa %ebx 0 x 0 %esp 0 x 10000 Adam Doupé, Principles of Programming Languages 11
Stack Example 0 x. FFFF … 0 xa push %eax pop %ebx 0 x 10000 … Garbage 0 x 0000 %eax 0 xa %ebx 0 x 0 %esp 0 x. FFFC Adam Doupé, Principles of Programming Languages 12
Stack Example 0 x. FFFF … 0 xa push %eax pop %ebx 0 x 10000 … Garbage 0 x 0000 %eax 0 xa %ebx 0 x 0 %esp 0 x. FFFC Adam Doupé, Principles of Programming Languages 13
Stack Example 0 x. FFFF … 0 xa push %eax pop %ebx 0 x 10000 … Garbage 0 x 0000 %eax 0 xa %ebx 0 xa %esp 0 x. FFFC Adam Doupé, Principles of Programming Languages 14
Stack Example 0 x. FFFF … 0 xa push %eax pop %ebx 0 x 10000 … Garbage 0 x 0000 %eax 0 xa %ebx 0 xa %esp 0 x 10000 Adam Doupé, Principles of Programming Languages 15
Function Frame • Functions would like to use the stack to allocate space for their local variables • Can we use the stack pointer for this? – Yes, however stack pointer can change throughout program execution • Frame pointer points to the start of the function's frame on the stack – Each local variable will be (different) offsets of the frame pointer – In x 86, frame pointer is called the base pointer, and is stored in %ebp Adam Doupé, Principles of Programming Languages 16
int main() { int a; int b; float c; a = 10; b = 100; c = 10. 45; a = a + b; return 0; } a @ %ebp + A b @ %ebp + B c @ %ebp + C a @ %ebp – 0 xc b @ %ebp – 0 x 8 c @ %ebp – 0 x 4 mem[%ebp+A] mem[%ebp+B] mem[%ebp+C] mem[%ebp+A] mem[%ebp+B] mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) = 100 = 10. 45 = + Adam Doupé, Principles of Programming Languages 17
Function Frame 0 x. FFFF … 0 x 10000 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax %esp 0 x 10000 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 18
Function Frame 0 x. FFFF … 0 x 10000 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax %esp 0 x 10000 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 19
Function Frame 0 x. FFFF … 0 x 10000 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 20
Function Frame 0 x. FFFF … 0 x 10000 0 x. FFFC 0 x. FFF 8 0 x. FFF 4 0 x. FFF 0 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 21
Function Frame 0 x. FFFF … 0 xa 0 x 10000 0 x. FFFC 0 x. FFF 8 0 x. FFF 4 0 x. FFF 0 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 22
Function Frame 0 x. FFFF … 0 xa 0 x 10000 0 x. FFFC 0 x. FFF 8 0 x. FFF 4 0 x. FFF 0 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 23
Function Frame 0 x. FFFF … 0 x 64 0 xa 0 x 10000 0 x. FFFC 0 x. FFF 8 0 x. FFF 4 0 x. FFF 0 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 24
Function Frame 0 x. FFFF … 0 x 64 0 xa 0 x 10000 0 x. FFFC 0 x. FFF 8 0 x. FFF 4 0 x. FFF 0 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 25
Function Frame 0 x. FFFF … 0 x 64 0 xa 0 x 10000 0 x. FFFC 0 x. FFF 8 0 x. FFF 4 0 x. FFF 0 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax 0 x 41273333 %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 26
Function Frame 0 x. FFFF … 0 x 64 0 xa 0 x 10000 0 x. FFFC 0 x. FFF 8 0 x. FFF 4 0 x. FFF 0 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax 0 x 41273333 %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 27
Function Frame 0 x. FFFF … 0 x 41273333 0 x 64 0 xa 0 x 10000 0 x. FFFC 0 x. FFF 8 0 x. FFF 4 0 x. FFF 0 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax 0 x 41273333 %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 28
Function Frame 0 x. FFFF … c 0 x 41273333 b 0 x 64 a 0 x 10000 0 x. FFFC 0 x. FFF 8 0 x. FFF 4 0 x. FFF 0 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax 0 x 41273333 %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 29
Function Frame 0 x. FFFF … c 0 x 41273333 b 0 x 64 a 0 x 10000 0 x. FFFC 0 x. FFF 8 0 x. FFF 4 0 x. FFF 0 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax 0 x 64 %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 30
Function Frame 0 x. FFFF … c 0 x 41273333 b 0 x 64 a 0 x 10000 0 x. FFFC 0 x. FFF 8 0 x. FFF 4 0 x. FFF 0 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax 0 x 64 %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 31
Function Frame 0 x. FFFF … c 0 x 41273333 b 0 x 64 a 0 x 6 E 0 x 10000 0 x. FFFC 0 x. FFF 8 0 x. FFF 4 0 x. FFF 0 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax 0 x 64 %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 32
Function Frame 0 x. FFFF … c 0 x 41273333 b 0 x 64 a 0 x 6 E 0 x 10000 0 x. FFFC 0 x. FFF 8 0 x. FFF 4 0 x. FFF 0 mov %esp, %ebp sub $0 x 10, %esp movl $0 xa, -0 xc(%ebp) movl $0 x 64, -0 x 8(%ebp) mov $0 x 41273333, %eax mov %eax, -0 x 4(%ebp) mov -0 x 8(%ebp), %eax add %eax, -0 xc(%ebp) 0 x 0000 %eax 0 x 64 %esp 0 x. FFF 0 %ebp 0 x 10000 Adam Doupé, Principles of Programming Languages 33
Functions • Declarations – Function name – Formal parameters (names and types) – Return type • Invocation – f(x 1, x 2, …, xk) – x 1, x 2, . . . , xk are expressions – x 1, x 2, . . . xk are called the actual parameters – Invoking function must create the frame on the stack with enough space to hold the actual parameters Adam Doupé, Principles of Programming Languages 34
Function Frames • Allows us to allocate memory for the function's local variables • However, when considering calling a function, what other information do we need? – Return value – Parameters – Our frame pointer – Return address (where to start program execution when function returns) – Local variables – Temporary variables Adam Doupé, Principles of Programming Languages 35
Calling Convention • All of the previous information must be stored on the stack in order to call the function • Who should store that information? – Caller? – Callee? • Thus, we need to define a convention of who pushes/stores what values on the stack to call a function – Varies based on processor, operating system, compiler, or type of call Adam Doupé, Principles of Programming Languages 36
x 86 Linux Calling Convention (cdecl) • Caller (in this order) – Pushes arguments onto the stack (in right to left order) – Pushes address of instruction after call • Callee – Pushes previous frame pointer onto stack – Creates space on stack for local variables – Ensures that stack is consistent on return – Return value in %eax register Adam Doupé, Principles of Programming Languages 37
int callee(int a, int b) { return a + b + 1; } prologue int main() { int a; a = callee(10, 40); return a; } epilogue prologue epilogue Adam Doupé, Principles of Programming Languages callee: push %ebp mov %esp, %ebp mov 0 xc(%ebp), %eax mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax add $0 x 1, %eax pop %ebp ret main: push %ebp mov %esp, %ebp sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) movl $0 xa, (%esp) callee mov %eax, -0 x 4(%ebp) mov -0 x 4(%ebp), %eax leave ret 38
0 x. FFFF 0 xfd 2 d 4 0 x 0000 %eax %edx %esp 0 xfd 2 d 4 %ebp 0 xfd 2 c 0 %eip 0 x 80483 a 5 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 39
0 x. FFFF 0 xfd 2 d 4 0 x 0000 %eax %edx %esp 0 xfd 2 d 0 %ebp 0 xfd 2 c 0 %eip 0 x 80483 a 5 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 40
0 x. FFFF 0 xfd 2 c 0 0 xfd 2 d 4 0 x 0000 %eax %edx %esp 0 xfd 2 d 0 %ebp 0 xfd 2 c 0 %eip 0 x 80483 a 5 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 41
0 x. FFFF 0 xfd 2 c 0 0 xfd 2 d 4 0 x 0000 %eax %edx %esp 0 xfd 2 d 0 %ebp 0 xfd 2 c 0 %eip 0 x 80483 a 5 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 42
0 x. FFFF 0 xfd 2 c 0 0 xfd 2 d 4 0 x 0000 %eax %edx %esp 0 xfd 2 d 0 %ebp 0 xfd 2 c 0 %eip 0 x 80483 a 6 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 43
0 x. FFFF 0 xfd 2 c 0 0 xfd 2 d 4 0 x 0000 %eax %edx %esp 0 xfd 2 d 0 %ebp 0 xfd 2 d 0 %eip 0 x 80483 a 6 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 44
0 x. FFFF 0 xfd 2 c 0 0 xfd 2 d 4 0 x 0000 %eax %edx %esp 0 xfd 2 d 0 %ebp 0 xfd 2 d 0 %eip 0 x 80483 a 8 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 45
0 x. FFFF 0 xfd 2 c 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 b 8 0 x 0000 %eax %edx %esp 0 xfd 2 b 8 %ebp 0 xfd 2 d 0 %eip 0 x 80483 a 8 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 46
0 x. FFFF 0 xfd 2 c 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 x 0000 %eax %edx %esp 0 xfd 2 b 8 %ebp 0 xfd 2 d 0 %eip 0 x 80483 ab Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 47
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 x 0000 %eax %edx %esp 0 xfd 2 b 8 %ebp 0 xfd 2 d 0 %eip 0 x 80483 ab Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 48
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 x 0000 %eax %edx %esp 0 xfd 2 b 8 %ebp 0 xfd 2 d 0 %eip 0 x 80483 b 3 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 49
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 x 0000 %eax %edx %esp 0 xfd 2 b 8 %ebp 0 xfd 2 d 0 %eip 0 x 80483 b 3 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 50
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 x 0000 %eax %edx %esp 0 xfd 2 b 8 %ebp 0 xfd 2 d 0 %eip 0 x 80483 ba Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 51
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 x 0000 %eax %edx %esp 0 xfd 2 b 4 %ebp 0 xfd 2 d 0 %eip 0 x 80483 ba Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 52
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 x 0000 %eax %edx %esp 0 xfd 2 b 4 %ebp 0 xfd 2 d 0 %eip 0 x 8048394 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 53
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 x 0000 %eax %edx %esp 0 xfd 2 b 4 %ebp 0 xfd 2 d 0 %eip 0 x 8048394 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 54
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax %edx %esp 0 xfd 2 b 0 %ebp 0 xfd 2 d 0 %eip 0 x 8048394 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 55
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax %edx %esp 0 xfd 2 b 0 %ebp 0 xfd 2 d 0 %eip 0 x 8048394 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 56
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax %edx %esp 0 xfd 2 b 0 %ebp 0 xfd 2 d 0 %eip 0 x 8048394 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 57
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax %edx %esp 0 xfd 2 b 0 %ebp 0 xfd 2 d 0 %eip 0 x 8048395 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 58
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax %edx %esp 0 xfd 2 b 0 %ebp 0 xfd 2 b 0 %eip 0 x 8048395 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 59
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax %edx %esp 0 xfd 2 b 0 %ebp 0 xfd 2 b 0 %eip 0 x 8048397 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 60
0 x. FFFF 0 xfd 2 c 0 0 xfd 2 d 4 0 xfd 2 d 0 main 0 x 28 callee 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax %edx %esp 0 xfd 2 b 0 %ebp 0 xfd 2 b 0 %eip 0 x 8048397 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 61
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 28 %edx %esp 0 xfd 2 b 0 %ebp 0 xfd 2 b 0 %eip 0 x 8048397 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 62
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 28 %edx %esp 0 xfd 2 b 0 %ebp 0 xfd 2 b 0 %eip 0 x 804839 a Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 63
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 28 %edx 0 xa %esp 0 xfd 2 b 0 %ebp 0 xfd 2 b 0 %eip 0 x 804839 a Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 64
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 28 %edx 0 xa %esp 0 xfd 2 b 0 %ebp 0 xfd 2 b 0 %eip 0 x 804839 d Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 65
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 32 %edx 0 xa %esp 0 xfd 2 b 0 %ebp 0 xfd 2 b 0 %eip 0 x 804839 d Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 66
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 32 %edx 0 xa %esp 0 xfd 2 b 0 %ebp 0 xfd 2 b 0 %eip 0 x 80483 a 0 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 67
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 0 %ebp 0 xfd 2 b 0 %eip 0 x 80483 a 0 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 68
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 0 %ebp 0 xfd 2 b 0 %eip 0 x 80483 a 3 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 69
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 0 %ebp 0 xfd 2 d 0 %eip 0 x 80483 a 3 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 70
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 4 %ebp 0 xfd 2 d 0 %eip 0 x 80483 a 3 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 71
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 4 %ebp 0 xfd 2 d 0 %eip 0 x 80483 a 3 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 72
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 4 %ebp 0 xfd 2 d 0 %eip 0 x 80483 a 4 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 73
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 4 %ebp 0 xfd 2 d 0 %eip 0 x 80483 bf Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 74
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 8 %ebp 0 xfd 2 d 0 %eip 0 x 80483 bf Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 75
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 8 %ebp 0 xfd 2 d 0 %eip 0 x 80483 bf Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 76
0 x. FFFF 0 xfd 2 c 0 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 bc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 8 %ebp 0 xfd 2 d 0 %eip 0 x 80483 bf Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 77
0 x. FFFF 0 xfd 2 c 0 0 x 33 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 cc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 8 %ebp 0 xfd 2 d 0 %eip 0 x 80483 bf Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 78
0 x. FFFF 0 xfd 2 c 0 0 x 33 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 cc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 8 %ebp 0 xfd 2 d 0 %eip 0 x 80483 c 2 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 79
0 x. FFFF 0 xfd 2 c 0 0 x 33 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 cc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 8 %ebp 0 xfd 2 d 0 %eip 0 x 80483 c 2 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 80
0 x. FFFF 0 xfd 2 c 0 0 x 33 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 cc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 b 8 %ebp 0 xfd 2 d 0 %eip 0 x 80483 c 5 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 81
0 x. FFFF 0 xfd 2 c 0 0 x 33 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 cc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 d 0 %ebp 0 xfd 2 d 0 %eip 0 x 80483 c 5 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 82
0 x. FFFF 0 xfd 2 c 0 0 x 33 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 cc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 d 0 %ebp 0 xfd 2 c 0 %eip 0 x 80483 c 5 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 83
0 x. FFFF 0 xfd 2 c 0 0 x 33 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 cc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 d 4 %ebp 0 xfd 2 c 0 %eip 0 x 80483 c 5 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 84
0 x. FFFF 0 xfd 2 c 0 0 x 33 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 cc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 d 4 %ebp 0 xfd 2 c 0 %eip 0 x 80483 c 5 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 85
0 x. FFFF 0 xfd 2 c 0 0 x 33 0 x 28 0 xa 0 x 80483 bf 0 xfd 2 d 0 0 xfd 2 d 4 0 xfd 2 d 0 0 xfd 2 cc 0 xfd 2 b 8 0 xfd 2 b 4 0 xfd 2 b 0 0 x 0000 %eax 0 x 33 %edx 0 xa %esp 0 xfd 2 d 4 %ebp 0 xfd 2 c 0 %eip 0 x 80483 c 6 Adam Doupé, Principles of Programming Languages callee: push %ebp 0 x 8048394 mov %esp, %ebp 0 x 8048395 mov 0 xc(%ebp), %eax 0 x 8048397 0 x 804839 a mov 0 x 8(%ebp), %edx lea (%edx, %eax, 1), %eax 0 x 804839 d 0 x 80483 a 0 add $0 x 1, %eax 0 x 80483 a 3 pop %ebp 0 x 80483 a 4 ret main: 0 x 80483 a 5 push %ebp 0 x 80483 a 6 mov %esp, %ebp 0 x 80483 a 8 sub $0 x 18, %esp movl $0 x 28, 0 x 4(%esp) 0 x 80483 ab 0 x 80483 b 3 movl $0 xa, (%esp) 0 x 80483 ba call 0 x 8048394 0 x 80483 bf mov %eax, -0 x 4(%ebp) 0 x 80483 c 2 mov -0 x 4(%ebp), %eax 0 x 80483 c 5 leave 0 x 80483 c 6 ret 86
Function Parameter Passing • How did the previous example pass parameters to the function callee? – Pushed the values onto the stack • What are the semantics of passing parameters to a function? • Multiple approaches – Pass by value – Pass by reference – Pass by name Adam Doupé, Principles of Programming Languages 87
Pass by Value • Values of the actual parameters at function invocation are calculated and then copied to the function – We have seen how this is done for C, a copy of the values are placed on the stack Adam Doupé, Principles of Programming Languages 88
#include <stdio. h> int x; void test(int x) { x = x + 5; printf("%dn", x); } int main() { int y = 4; test(y); printf("%dn", y); return y; } Adam Doupé, Principles of Programming Languages [adamd@ragnuk]$ gcc –Wall pass_by_value. c [adamd@ragnuk]$. /a. out 9 4 x 9 4 y 4 89
Pass by Reference • The formal parameters are bound to the locations associated with the actual parameters – Thus, the actual parameters must be l-values Adam Doupé, Principles of Programming Languages 90
#include <stdio. h> int x; void test(int& x) { x = x + 5; printf("%dn", x); } int main() { int y = 4; test(y); printf("%dn", y); return y; } Adam Doupé, Principles of Programming Languages [adamd@ragnuk]$ g++ –Wall pass_by_value. c [adamd@ragnuk]$. /a. out 9 9 x y 9 4 91
Pass by name • The formal parameters are replaced by the text of the actual parameters everywhere in the function that the formal parameters occur Adam Doupé, Principles of Programming Languages 92
#include <stdio. h> int x; void test(int x) { x = x + 5; printf("%dn", x); } int main() { int y = 4; test(y); printf("%dn", y); return y; } Adam Doupé, Principles of Programming Languages [adamd@ragnuk]$ gcc –Wall pass_by_name_1. c [adamd@ragnuk]$. /a. out 9 9 void test(int y) { y = y + 5; printf("%dn", y); } 93
#include <stdio. h> int i; int a[10]; void inc(int x) { i++; x++; } int main() { i = 1; a[1] = 1; a[2] = 2; inc(a[i]); printf("%dn%dn", i, a[1], a[2]); return 0; } Adam Doupé, Principles of Programming Languages [adamd@ragnuk]$ gcc –Wall pass_by_name_2. c [adamd@ragnuk]$. /a. out 2 1 3 void inc(int a[i]) { i++; a[i]++; } 94
#include <stdio. h> int i; int p(int y) { int j = y; i++; return j + y; } void q() { int j = 2; i = 0; printf("%dn", p(i+j)); } [adamd@ragnuk]$ gcc –Wall pass_by_name_3. c [adamd@ragnuk]$. /a. out 5 int p(int (i+j)) { int j = (i+j); i++; return j + (i+j); } int main() { q(); return 0; } Adam Doupé, Principles of Programming Languages 95
#include <stdio. h> int foo(int test) { return 10; } int main() { int a = 0; int b = foo(a++); printf("%dn", a, b); return 0; } Adam Doupé, Principles of Programming Languages [adamd@ragnuk]$ gcc –Wall pass_by_name_4. c [adamd@ragnuk]$. /a. out 0 10 int foo(int a++) { return 10; } 96
[adamd@ragnuk]$ gcc –Wall pass_by_name_simulation. c [adamd@ragnuk]$. /a. out 5 #include <stdio. h> int i; int p(int y) { int j = y; i++; return j + y; } void q() { int j = 2; i = 0; printf("%dn", p(i+j)); } int main() { q(); return 0; } Adam Doupé, Principles of Programming Languages #include <stdio. h> int i, j; int i_plus_j() { return i+j; } int p(int (*y)(void)) { int j = y(); i++; return j + y(); } void q() { j = 2; i = 0; printf("%dn", p(i_plus_j)); } int main() { q(); return 0; } 97
Java • What is the parameter passing semantics of Java? – Pass by value? – Pass by reference? – Pass by name? Adam Doupé, Principles of Programming Languages 98
class Testing { int foo; } public class Parameter. Passing { public static void main(String [] args) { Testing bar = new Testing(); Testing snap = new Testing(); bar. foo = 0; snap. foo = 10; Pass. By. Question. Mark(bar, snap); System. out. println(bar. foo + "n" + snap. foo); } public static void Pass. By. Question. Mark(Testing a, Testing b) { b = new Testing(); b. foo = 100; a. foo = 42; } } Adam Doupé, Principles of Programming Languages 99
Java • Essentially pass by value and assignment share semantics • Note that this is not standard terminology • How is it implemented under-the-hood? Adam Doupé, Principles of Programming Languages 100
Local Functions • From what we have seen so far, variables are either global or local • What if we want a language that allows defining local functions – Functions that are only valid in the containing scope Adam Doupé, Principles of Programming Languages 101
#include <stdio. h> void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } } baz(); } x = 0; bar(); printf("%dn", x); } Adam Doupé, Principles of Programming Languages [adamd@ragnuk]$ gcc –Wall local_functions. c [adamd@ragnuk]$. /a. out 10 102
Local Functions • Can the previously discussed cdecl calling convention support local functions? Adam Doupé, Principles of Programming Languages 103
foo #include <stdio. h> void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } } baz(); } x = 0; bar(); printf("%dn", x); } Adam Doupé, Principles of Programming Languages 104
foo bar #include <stdio. h> void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } } baz(); } x = 0; bar(); printf("%dn", x); } Adam Doupé, Principles of Programming Languages 105
foo bar #include <stdio. h> void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } } baz(); } x = 0; bar(); printf("%dn", x); } Adam Doupé, Principles of Programming Languages 106
foo bar #include <stdio. h> baz void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } } baz(); } x = 0; bar(); printf("%dn", x); } Adam Doupé, Principles of Programming Languages 107
foo bar #include <stdio. h> baz void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } } baz(); } x = 0; bar(); printf("%dn", x); } Adam Doupé, Principles of Programming Languages 108
foo bar #include <stdio. h> baz void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } } baz(); } x = 0; bar(); printf("%dn", x); } bar Adam Doupé, Principles of Programming Languages 109
foo bar #include <stdio. h> baz void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } } baz(); } x = 0; bar(); printf("%dn", x); } bar Adam Doupé, Principles of Programming Languages baz 110
foo bar #include <stdio. h> baz void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } } baz(); } x = 0; bar(); printf("%dn", x); } bar Adam Doupé, Principles of Programming Languages baz 111
Access Link • Saved base pointer (EBP) save the caller's base pointer • We want the base pointer of our lexical parent, not our caller's parent • Thus, we need to add another element to our calling convention – This is called the "access link" • Therefore, a function can follow the access links until the last lexical scope is found Adam Doupé, Principles of Programming Languages 112
foo bar #include <stdio. h> baz void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } } baz(); } x = 0; bar(); printf("%dn", x); } bar Adam Doupé, Principles of Programming Languages baz 113
foo bar #include <stdio. h> baz void foo() { int x; void bar() { void baz() { x = x + 1; if (x < 10) { bar(); } } baz(); } x = 0; bar(); printf("%dn", x); } bar Adam Doupé, Principles of Programming Languages baz bar baz 114