Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(50 points) Consider the following assembly code for long loop_for (long x, long n ) ;. The first argument x is in %rdi and second

image text in transcribed

(50 points) Consider the following assembly code for long loop_for (long x, long n ) ;. The first argument x is in \%rdi and second argument n is in \%rsi. The return value of loop_for is returned through \%rax. \( \begin{array}{cl}\text { loop_for: } & \\ \text { movq } & \% r \mathrm{rsi}, \% \mathrm{rcx} \\ \text { movq } & \$ 1, \% r d x \\ \text { movq } & \$ 0, \% \mathrm{rax} \\ \text { jmp } & . \text { L6 } \\ \text {.L5: } & \\ \text { movq } & \% r d i, \% r 8 \\ \text { andq } & \% r d x, \% r 8 \\ \text { orq } & \% r 8, \% r a x \\ \text { salq } & \% r c x, \% r d x \\ \text {.L6: } & \\ \text { testq } & \% r d x, \% r d x \\ \text { jne } & . \text { L5 } \\ \text { ret } & \end{array} \) Fill in the C code for loop_for that will have an effect equivalent to the assembly code shown

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

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students also viewed these Databases questions