Question: Problem 3 [20 points) Equivalent C code: Consider the following blocks of code: .file hw3.c .text globl main .type main, @function main: pushq%rbp movq rsp,

Problem 3 [20 points) Equivalent C code: Consider the following blocks of code: .file "hw3.c" .text globl main .type main, @function main: pushq%rbp movq rsp, %rbp movl $5, -12%rbp) movl $30, -4%rbp) movl $15, -8%rbp) .L3: cmpl $1,-8(%rbp) je .L2 movl -4%rbp), %eax imull -12%rbp), %eax movl %eax, -4%rbp) subl $1,-8(%rbp) jmp L3 .L2: movl -8%rbp), %eax imull -12rbp), %eax movl %eax, -8%rbp) movl $0.%eax popq %rbp ret Consider the compiler places the C variables: b at -4%rbp), c at-8%rbp), and a at-12(rbp). a) Fill out the C code based on the Assembly code given. (15p) b) What is the size (in bytes) of variable c? Why? (5p) Problem 3 [20 points) Equivalent C code: Consider the following blocks of code: .file "hw3.c" .text globl main .type main, @function main: pushq%rbp movq rsp, %rbp movl $5, -12%rbp) movl $30, -4%rbp) movl $15, -8%rbp) .L3: cmpl $1,-8(%rbp) je .L2 movl -4%rbp), %eax imull -12%rbp), %eax movl %eax, -4%rbp) subl $1,-8(%rbp) jmp L3 .L2: movl -8%rbp), %eax imull -12rbp), %eax movl %eax, -8%rbp) movl $0.%eax popq %rbp ret Consider the compiler places the C variables: b at -4%rbp), c at-8%rbp), and a at-12(rbp). a) Fill out the C code based on the Assembly code given. (15p) b) What is the size (in bytes) of variable c? Why? (5p)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
