{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

homework4_sol

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

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

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

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

View Full Document
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

• 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.

Kiran Temple University Fox School of Business â€˜17, Course Hero Intern

• 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.

Dana University of Pennsylvania â€˜17, Course Hero Intern

• 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.

Jill Tulane University â€˜16, Course Hero Intern