{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

homework4_sol - 0xFF 0x104 0xAB 0x108 0x13 0x10C 0x11 Table...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Homework 4 Problem 1 Consider the following 3 calls to show_bytes: void show_bytes(byte_pointer start, int len) { int i; for (i = 0; i < len; i++) printf(" %.2x", start[i]); printf("\n"); } int val = 0x12345678; byte_pointer valp = (byte_pointer) &val; show_bytes(valp, 1); /* A. */ show_bytes(valp, 2); /* B. */ show_bytes(valp, 3); /* C. */ Indicate below the values that would be printed by each call on a little-endian machine and on a bigendian machine. A. Little endian: 78 Big endian: 12 B. Little endian: 78 56 Big endian: 12 34 C. Little endian: 78 56 34 Big endian: 12 34 56 Problem 2 Fill the table 3 according to the value of register and memory. Address Value
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
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 0xFF 0x104 0xAB 0x108 0x13 0x10C 0x11 Table 1 Register Value %eax 0x100 %ecx 0x1 %edx 0x3 Table 2 Instruction Destination Value addl %ecx, (%eax) 0x100 0x100 subl %edx, 4(%eax) 0x104 0xA8 imull $16, (%eax, %edx, 4) 0x10C 0x110 incl 8(%eax) 0x108 0x14 decl %ecx %ecx 0x0 subl %edx, %eax %eax 0xFD Table 3 Problem 3 According to the following X86 assemble code, complete the C source file with proper expressions or operands func_A: pushl %ebp movl %esp, %ebp jmp .L2 .L3: movl 12(%ebp), %eax subl %eax, 8(%ebp) .L2: movl 8(%ebp), %eax cmpl 12(%ebp), %eax jg .L3 movl 8(%ebp), %eax popl %ebp ret int func_A(int a, int b) { while ( a>b ) a=a-b ; return a ; }...
View Full 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