{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

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

Info icon This 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
Image of page 1

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

View Full Document Right 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
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)
Image of page 3

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

View Full Document Right 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
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
Image of page 5

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

View Full Document Right 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;
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
Image of page 7

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

View Full Document Right 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
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
Image of page 9

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

View Full Document Right 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
Image of page 10
11 IA-32
Image of page 11

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern