Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the following assembly code: .LC0 .string ans %d main: .LFB0: pushq %rbp movq %rsp, %rbp subq $16, %rsp movabsq $53162464113523643, %rax movq %rax,

Using the following assembly code:

.LC0 .string "ans %d " main:

.LFB0:

pushq %rbp

movq %rsp, %rbp

subq $16, %rsp

movabsq $53162464113523643, %rax

movq %rax, -8(%rbp)

movl $0, -12(%rbp) jmp .L2

.L3:

movq -8(%rbp), %rax

movl %eax, %edx andl $1, %edx

movl -12(%rbp), %eax

addl %edx, %eax

movl %eax, -12(%rbp)

sarq -8(%rbp)

.L2:

cmpq $0, -8(%rbp)

jg .L3

movl -12(%rbp), %eax

movl %eax, %esi

movl $.LC0, %edi

movl $0, %eax

call printf

leave

ret

This code came from the following skeleton C file, and optimized with O0, so gcc -O0 -S was the exact command to compile the file. Step 1 might be to ignore the skeleton file and create a C file from the assembly code, and then rewrite the code to fit the skeleton file.

int main() {

long int val=_________;

int result=_________;

for(;val>_________;val=_________)

result += ___________;

printf("ans %d ",result);

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems Asian Conference Aciids 2012 Kaohsiung Taiwan March 2012 Proceedings Part 2 Lnai 7197

Authors: Jeng-Shyang Pan ,Shyi-Ming Chen ,Ngoc-Thanh Nguyen

2012th Edition

3642284892, 978-3642284892

Students also viewed these Databases questions

Question

What is the purpose of the staffing practice called Two-in-a-Box?

Answered: 1 week ago