CS计算机代考程序代写 prolog x86 Problem4

Problem4
Problem #4 Worksheet

Your job is to show what the stacks will look like after swap() returns in each of the two programs: program4a and program 4b
You need to fill in the yellow boxes if they are blank and update the yellow boxes if they need adjustment

LC4’s Data Memory (Stack for Program 4a) LC4’s Data Memory (Stack for Program 4b)
Address Contents Description Address Contents Description

x7FF5 local variable in swap() x7FF5 local variable in swap()
x7FF6 caller’s frame pointer x7FF6 caller’s frame pointer
x7FF7 caller’s return address x7FF7 caller’s return address
x7FF8 2nd argument to swap() x7FF8 2nd argument to swap()
x7FF9 1st argument to swap() x7FF9 1st argument to swap()
x7FFA 10 b – local variable in main x7FFA 10 b – local variable in main
x7FFB 5 a – local variable in main x7FFB 5 a – local variable in main
x7FFC x0000 caller’s frame pointer x7FFC x0000 caller’s frame pointer
x7FFD x0005 caller’s return address x7FFD x0005 caller’s return address
x7FFE X main()’s return value x7FFE X main()’s return value
x7FFF X arguments to main x7FFF X arguments to main
In both cases, the values of R5, R6, and R7 – right after the JSR() to swap() occurs – but before the prologue of swap() occurs are:
R5 = x7FFC
R6 = x7FF8
R7 = x0075
Question: Using your completed stack diagrams, explain in words why program4b succeeds in swapping a & b and why program4a does not:
Your answer:

Problem7
Problem #7 Worksheet

Your job is to show the stack on the x86
Looking at program7.c and its output will help you fill in this chart. One sample entry is shown below.
While you can’t determine the value of the frame pointer, RA, or arguments to main…you can determine their address, using a’s address to help you

x86’s Data Memory (Stack for Problem 7)

Address Contents Description

0x7ffc79279d10 0x7ffdb65a7c78 local variable (a_ptr) <- This line is an example, your memory address (and contents) will be different! 0x7ffdb65a7c78 5 local variable (a) <- This line is an example, your memory address will be different! X caller's frame pointer X caller's return address 0 main()'s return value X arguments to main Question: what is the address space of the x86 you are working on? Your answer: