Question

Match each of the assembler routines with the equivalent C functions. Note: shrq is the logical...

Match each of the assembler routines with the equivalent C functions. Note: shrq is the logical right shift instruction,
and sarq is the arithmetic right shift instruction.

Question 3 options:

foo5:
leaq -4(%rdi), %rax
shrq $63, %rax
ret

foo2:
movq %rdi, %rax
salq $4, %rax
ret

foo3:
movq %rdi, %rax
sarq $4, %rax
ret

foo4:
leaq 4(%rdi), %rax
ret

foo1:
leaq 0(,%rdi,4), %rax
ret

1.

long choice1(long x)
{
return x - 4 < 0;
}

2.

long choice2(long x)
{
return 4*x;
}

3.

long choice3(long x)
{
return x>>4;
}

4.

long choice4(long x)
{
return x*16;
}

5.

long choice5(long x)
{
return x+4;
}

6.

long choice6(long x)
{
return x+8;
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1-1 [foo5 - choice1] because leaq will add -4 to x and shrq will check <0

2-4[foo2 -choice4] 4 time left shift means multiply by 16

3-3[foo3-choice3] right shift

4-5 [foo4-choice5] leaq will add 4 to x

5-2 [foo1-choice2] leaq will add as 0 + 4*x

PLEASE UPVOTE

Add a comment
Know the answer?
Add Answer to:
Match each of the assembler routines with the equivalent C functions. Note: shrq is the logical...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Question 4 (2 points) Consider the C statements below. Assume x has been assigned a value....

    Question 4 (2 points) Consider the C statements below. Assume x has been assigned a value. int mask = 0xFF000000; y = x ^ mask; Which one of the following best describes the value computed for variable y? Question 4 options: y contains the most significant byte of x complemented, with the rest of the bits unchanged y contains the most significant byte of x unchanged, with the rest of the bits 0 y contains the most significant byte of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT