Question: For the C code below, if the variables a1 and a1p are changed to: int a1, int *a1p, and everything else remains the same. Then

For the C code below, if the variables a1 and a1p are changed to: int a1, int *a1p, and everything else remains the same. Then compile the C code to X86-32 assembly code (similar to the assembly code in Figure 3.29 which is X86-64 though).

Write the corresponding X86-32 assembly code and draw the stack frame for the revised function proc.For the C code below, if the variables a1 and a1p are

---------------------------------------------

Computer System C coding problem.

Procedures problem.

Please read carefully and ONLY FULL ANSWERS will get positive rate. Thank you.

(a) C code void proc(long al, long *aip, int a2, int. 4a2p, short a3, short *a3p, char a4, char *a4p) *a2p +- a2; (b) Generated assembly code void proc(a1, alp, a2, a2p, as, a3p, a4, a4p) Arguments passed as follovs: (64 bits) (64 bits) (32 bits) (64 bits) (16 bits) (64 bits,) ( 8 bits) (64 bits) al in %rdi alp, in %fsi a2 in %eax a2p in %rcx a4 at %rsp+8 24p at %rsp+16 1 proc: 16(%rbp), Zrax (64 bits) Fetch a4p *alp += a1 (64 bits) *a2pa2 (32 bits) *a3p a3 (16 bits) Fetch a4 *a4p +- a4 (8 bits) Return movq %edx 8CXrsp), %d1 , ( 8 bits) movi addb ret (%rax) Figure 3.29 Example of function with multiple arguments of different types. Arguments 1-6 are passed in registers, while arguments 7-8 are passed on the stac k. Figure 3.30 Stack frame structure for function proc. Arguments a4 and a4p' are passed on the stack. a4p 16 Stack pointer Return address +--%tsp (a) C code void proc(long al, long *aip, int a2, int. 4a2p, short a3, short *a3p, char a4, char *a4p) *a2p +- a2; (b) Generated assembly code void proc(a1, alp, a2, a2p, as, a3p, a4, a4p) Arguments passed as follovs: (64 bits) (64 bits) (32 bits) (64 bits) (16 bits) (64 bits,) ( 8 bits) (64 bits) al in %rdi alp, in %fsi a2 in %eax a2p in %rcx a4 at %rsp+8 24p at %rsp+16 1 proc: 16(%rbp), Zrax (64 bits) Fetch a4p *alp += a1 (64 bits) *a2pa2 (32 bits) *a3p a3 (16 bits) Fetch a4 *a4p +- a4 (8 bits) Return movq %edx 8CXrsp), %d1 , ( 8 bits) movi addb ret (%rax) Figure 3.29 Example of function with multiple arguments of different types. Arguments 1-6 are passed in registers, while arguments 7-8 are passed on the stac k. Figure 3.30 Stack frame structure for function proc. Arguments a4 and a4p' are passed on the stack. a4p 16 Stack pointer Return address +--%tsp

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 Databases Questions!