Question: Problem A [4 points per C code blank, 2 points per table entry = 40 points) Consider the following blocks of code: Assembly Code: C

 Problem A [4 points per C code blank, 2 points per

Problem A [4 points per C code blank, 2 points per table entry = 40 points) Consider the following blocks of code: Assembly Code: C Code int main(){ unsigned x = _ int c = 0; int s = for(int i = 0; S = x= .file "hw4a.c" .text .globl main .type main, @function main: pushq%rbp movq %rsp, %rbp movl $1889785064, -16(%rbp) movl $0,-12%rbp) movl $-1,-4(%rbp) movl $0,-8(%rbp) jmp.L2 14: movl -16%rbp), %eax andl $1,%eax movl %eax, -41%rbp) cmpl $0, -4%rbp) jne.L3 addl $1, -12%rbp) .L3: shrl $4, -16%rbp) addl $1,-8(%rbp) .L2: cmpl $7,-8(%rbp) jle L4 movl $0,%eax popq %rbp ret return 0; The assembly code on the left came from the skeleton C file on the right after optimizing with -00. ("gcc-00 -S-fno- asynchronous-unwind-tables", the last option was used to disable cfi directives). Complete the C code based on the Assembly code given. It may help to first fill out the table below to map the registers/addresses to the C variables Assembly address/register C variable Problem A [4 points per C code blank, 2 points per table entry = 40 points) Consider the following blocks of code: Assembly Code: C Code int main(){ unsigned x = _ int c = 0; int s = for(int i = 0; S = x= .file "hw4a.c" .text .globl main .type main, @function main: pushq%rbp movq %rsp, %rbp movl $1889785064, -16(%rbp) movl $0,-12%rbp) movl $-1,-4(%rbp) movl $0,-8(%rbp) jmp.L2 14: movl -16%rbp), %eax andl $1,%eax movl %eax, -41%rbp) cmpl $0, -4%rbp) jne.L3 addl $1, -12%rbp) .L3: shrl $4, -16%rbp) addl $1,-8(%rbp) .L2: cmpl $7,-8(%rbp) jle L4 movl $0,%eax popq %rbp ret return 0; The assembly code on the left came from the skeleton C file on the right after optimizing with -00. ("gcc-00 -S-fno- asynchronous-unwind-tables", the last option was used to disable cfi directives). Complete the C code based on the Assembly code given. It may help to first fill out the table below to map the registers/addresses to the C variables Assembly address/register C variable

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!