{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

homework4

# homework4 - Address Value 0x100 0xFF 0x104 0xAB 0x108 0x13...

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: Big endian: B. Little endian: Big endian: C. Little endian: Big endian: Problem 2 Fill the table 3 according to the value of register and memory.

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: Address Value 0x100 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) subl %edx, 4(%eax) imull \$16, (%eax, %edx, 4) incl 8(%eax) decl %ecx subl %edx, %eax 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 ( â‘  ) â‘¡ ; return â‘¢ ; }...
View Full Document

{[ snackBarMessage ]}