Question: the C function p 7 is compiled to the x 8 6 code shown on the right ( the integer array p is created elsewhere

the C function p7 is compiled to the x86 code shown on the right (the integer array p is created elsewhere in the x86 code).complete the definition of the C function p7 on the left, so that it does the same thing as the assembly code on the right. [mov2XY transfers data of size X from the source register to overwrite data of size Y in the destination register, sets any extra bits of the destination to 0's (X and Y can be b, w, l, or q for 8-,16-,32-, and 64-bit, respectively). movsXY does the same, except the sign but of the source is extended in the destination. cltq is equivalent to movslq %eax %rax.] const int p[]={13,15,8,11,5,14,7}; int p7(char s[], int n){ int c; int d=0; for (int i=0; # a in %rdi, n in %esi p7: pushq %rbp movq %rsp,%rbp movq %rdi, -24(%rbp) movl %esi, -28(%rbp) movl $0,-4(%rbp) movl $0,-8(%rbp) jmp .L2.L3: movl -8(%rbp),%eax movslq %eax, %rdx movq -24(%rbp),%rax addq %rdx,%rax movzbl (%rax), $eax movsbl %a1,%eax andl $7,%eax movl %eax, -12(%rbp) movl -12(%rbp),%eax cltq movl p(,%rax,4),%eax addl %eax, -4(%rbp) addl $1,-8(%rbp).L2: movl -8(%rbp),%eax movslq %eax, %rdx movq -24(%rbp),%rax addq %rdx,%rax movzbl (%rax),%eax testb %al,%al jne .L3 cmpl $31,-4(%rbp) jne .L4 movl $0,%eax jmp .L5.L4: movl $-1,%eax .L5: popq %rbp retff

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!