7 - Machine-Level Representation of Programs III 1 Outline...

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Machine-Level Representation of Programs III
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 Outline Hardware stack Pointers and word size Chap 3.4.2, 3.4.3, 2.1.4, 2.1.2, 2.1.3
Background image of page 2
3 Addressing mode Constant  & variable f() { int  i  =  3  ; } Immediate & memory 00000000 <_f>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 ec 14 sub $0x14,%esp 6: c7 45 fc movl , d: c9 leave e: c3 ret $0x3 03 00 00 00 -0x4(%ebp)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sequential execution 00000000 <_f>: 0: 55 push %ebp 1: 89 e5 mov %esp,%ebp 3: 83 ec 14 sub $0x14,%esp 6: c7 45 fc 03 00 00 00 movl $0x3,-0x4(%ebp) d: c9 leave e: c3 ret c3 ret c9 leave c 00 00 00 03 8 fc 45 c7 movl $0x3,- 0x4(%ebp) 14 4 ec 83 sub $0x14,%esp e5 00 00 00 00 PC 00 00 00 01 PC 00 00 00 03 PC 00 00 00 06 PC 00 00 00 0d PC 00 00 00 0e PC
Background image of page 4
5 Code Layout kernel virtual memory Read only code Read only data Read/write data forbidden memory invisible to user code Linux/x86 process memory image 0xffffffff 0xc0000000 0x08048000 % e ip
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Review (C Code) include <stdio.h> nt accum = 0; int main() { int s; s = sum(4,3); printf(" %d %d \n", s, accum); return 0; } nt sum(int x, int y) int t = x + y; accum += t; return t;
Background image of page 6
7 Review (object Code) 08048360 <sum>: 8048360: 55 push %ebp 8048361: 89 e5 mov %esp,%ebp 8048363: 8b 45 0c mov 0xc(%ebp) ,%eax 8048366: 8b 55 08 mov 0x8(%ebp) ,%edx 8048369: 5d pop %ebp 804836a: 01 d0 add %edx,%eax 804836c: 01 05 f0 95 04 08 add %eax, 0x80495f0 8048372: c3 ret
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Review (object Code) 08048360 <sum>: 8048360: 55 push %ebp 8048361: 89 e5 mov %esp,%ebp 8048363: 8b 45 0c mov 0xc(%ebp),%eax 8048366: 8b 55 08 mov 0x8(%ebp),%edx 8048369: 5d pop %ebp 804836a: 01 d0 add %edx,%eax 804836c: 01 05 f0 95 04 08 add %eax, 0x80495f0 8048372: c3 ret
Background image of page 8
9 Processor states Registers %eax, %ebx, %ecx, %edx, %esi, %edi, %esp, %ebp Program counter %eip Conditional Codes ZF, CF, SF, OF Memory
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10 Assembly Programmer’s View FF BF 7F 3F C0 80 40 00 Stack DLLs Text Data Heap Heap 08 %eax %edx %ecx %ebx %esi %edi %esp %ebp %al %ah %dl %dh %cl %ch %bl %bh %eip %eflag Addresses Data Instructions
Background image of page 10
11 IA-32
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
12 Stack operation
Background image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/19/2011 for the course CS 000 taught by Professor Jing during the Fall '10 term at Fudan University.

Page1 / 40

7 - Machine-Level Representation of Programs III 1 Outline...

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online