Question: the C function p 9 is compiled to the x 8 6 code shown on the right. complete the C function p 9 on the

the C function p9 is compiled to the x86 code shown on the right. complete the C function p9 on the left using a while loop, so that it does the same thing as the compiled x86 code. long p9(long *val){ # *val in %rdi p9: pushq %rbp movq %rsp,%rbp movq %rdi, -24(%rbp) movq $0,-8(%rbp) movl $6,-12(%rbp) jmp .L2.L5: movl -12(%rbp),%eax cltq leaq 0(,%rax,8),%rdx movq -24(%rbp),%rax addq %rdx,%rax movq (%rax),%rax testq %rax, %rax jne .L3 subl $1,-12(%rbp) jmp .L2.L3 movq $-1,-8(%rbp) jmp .L4.L2: cmpl $0,-12(%rbp) jg .L5.L4: movq -8(%rbp),%rax popq %rbp ret

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!