QuestionQuestion

Transcribed TextTranscribed Text

Disassemble x86-64 Code Consider the following assembly code: The preceding code was generated by compiling C code that had the following overall form: long loop(long x, long n) { long result = __________; long mask; for (mask = __________; mask __________; mask = ______________) { result |= _______________; } return result; } Your task is to fill in the missing parts of the C code to get a program equivalent to the generated assembly code. Recall that the result of the function is returned in register %rax. You will find it helpful to examine the assembly code before, during and after the loop to form a consistent mapping between the registers and the program variables. A. Which registers hold program values x, n, result, and mask? B. What are the initial values of result and mask? Variable x n result mask Register variables result mask initial value

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

long loop(long x, long n)
{
long result = 0;
long mask;
for (mask = 1; mask != 0; mask = mask << (n & 0xFF)) {
result|= x & mask;
}...
$25.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats