






































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Process Memory Model, IA32 stack organization, Register Saving conventions, Before and After main(), Project
Typology: Slides
1 / 46
This page cannot be seen from the preview
Don't miss anything!







































(^) If I have asked you for data, please provide it!
(^) Lots of registers, registers more orthogonal
(^) Machine begins in 16-bit mode, then 32, finally 64 » You don't have time to write 32 ⇒ 64 transition code » If we gave it to you, it would be a^ big^ black box
(^) More registers means more registers to have wrong values
(^) More steps than x86-32, but not more intellectually stimulating
(^) ...which can boot and run your personal OS
kernel virtual memory (code, data, heap, stack) memory mapped region for shared libraries run-time heap (managed by malloc) user stack (created at runtime) unused 0 %esp (stack pointer) memory invisible to user code brk 0xc 0x 0x read/write segments (.data, .bss) read-only segments (.init, .text, .rodata) loaded from the executable file 0xffffffff
Stack Libraries Text Data 08
Stack Libraries Text Data Heap 08
Stack Libraries Text Data Heap Heap 08
Stack Text Data 08
(^) address of “top” element (^) stack pointer Stack Pointer %esp Stack Grows Down Increasing Addresses Stack “Top” Stack “Bottom”
Stack Pointer %esp Stack Grows Down Increasing Addresses Stack “Top” Stack “Bottom” +
%esp %eax %edx %esp %eax %edx %esp %eax %edx 0x 555 0x 0x 0x10c 0x 0x 555
0x 0x10c 0x 555
0x108 0x pushl %eax 0x 0x10c 0x 213
0x
popl %edx 0x
%esp %eip %esp %eip 0x804854e 0x 0x 0x10c 0x 0x 0x804854e 0x
0x 0x10c 0x 123 0x call 8048b 804854e: e8 3d 06 00 00 call 8048b90
%esp %eip 0x %esp 0x8048591 %eip 0x 0x104 0x 0x 0x10c 0x 0x
0x 0x10c 0x 123 ret 8048591: c3 ret 0x %eip is program counter 0x 0x
yoo(…) {
} who(…) {
} yoo who amI amI amI
amI
Stack Pointer %esp yoo who proc Frame Pointer %ebp Stack “Top”
(^) “Set-up” code
(^) “Finish” code
amI
void swap(int *xp, int *yp) { int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; } int zip1 = 15213; int zip2 = 91125; void call_swap() { swap(&zip1, &zip2); } call_swap:
void swap(int *xp, int *yp) { int t0 = *xp; int t1 = *yp; *xp = t1; *yp = t0; } swap: pushl %ebp movl %esp,%ebp pushl %ebx movl 12(%ebp),%ecx movl 8(%ebp),%edx movl (%ecx),%eax movl (%edx),%ebx movl %eax,(%edx) movl %ebx,(%ecx) movl -4(%ebp),%ebx movl %ebp,%esp popl %ebp ret Body Set Up Finish Core