Question: 1 . Write a C function max 3 that takes three numbers a , b , c and returns the maximum of the three numbers.

1. Write a C function max3 that takes three numbers a, b, c and returns the maximum of the three
numbers.
a. Use the gcc compiler to generate the assembly code.
b. Use the gcc compiler to generate the object code.
c. Use the objdump to decompile the object code. Redirect the output into a file.
Submit the C, assembly, and the decompiled object code for the above program.
2. Extend the program to include a main function to test the function.
a. Use the gcc compiler to generate the assembly code.
b. Use the gcc compiler to generate the object code.
c. Use the objdump to decompile the object code. Redirect the output into a file.
Submit the C, assembly, and the decompiled object code for the above program.
3. Assume the following values are stored at the indicated memory addresses and registers:
Address Value Register Value
0x2000xFF %rax 0x200
0x2040xAA %rcx 0x1
0x2080x11%rdx 0x3
0x20C 0x13
Fill in the following table showing the values for the indicated operands:
Operand Value
%rax _______
0x204_______
$0x208_______
(%rax)_______
4(%rax)_______
9(%rax,%rdx)_______
260(%rcx,%rdx)_______
0xFC(,%rcx,4)_______
(%rax,%rdx,4)_______
4. You are given the following information. A function with prototype
int mystery(int a, int b, int c, int d);
is compiled into assembly code. The body of the code is as follows:
leal (%rdi,%rsi,2),%eax
leal (%rdx,%rdx,2),%edx
addl %edx, %eax
leal (%rax,%rcx,4),%eax
ret
Assume a at rdi, b at rsi, c at rdx, d at rcx, and the return value at eax.
Write the C code for mystery function that will have an effect equivalent to the assembly code
above.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!