homework4_sol

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

Info iconThis 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background image of page 2
Background 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

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 / 3

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

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

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