Question

Assume that we are using the x86-64 architecture Convert the following code fragment (in the C...

Assume that we are using the x86-64 architecture

Convert the following code fragment (in the C language) to assembly code.
Explain your steps. [25 marks]

long test ( long a, long b, long c ) {
long t;
if (a>b) {
if (a>c)
t=a;
else
t=c;
} else {
t=b;
}
return t;
}

0 0
Add a comment Improve this question Transcribed image text
Know the answer?
Add Answer to:
Assume that we are using the x86-64 architecture Convert the following code fragment (in the C...
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 2 Assume that we are using the x86-64 architecture, as mentioned in lecture 4. 2(a)...

    Question 2 Assume that we are using the x86-64 architecture, as mentioned in lecture 4. 2(a) Explain the meaning of the following instruction: movq %rbx, (%rcx)         State your assumptions of the content in registers and memory, before executing this instruction.         What will happen after executing this instruction? (b)Convert the following code fragment (in the C language) to assembly code. Explain your steps. [25 marks] long test ( long a, long b, long c ) { long t; if...

  • Assume that we are using the x86-64 architecture, as mentioned in lecture 4. 2(a)  Explain the meaning...

    Assume that we are using the x86-64 architecture, as mentioned in lecture 4. 2(a)  Explain the meaning of the following instruction:                movq %rbx, (%rcx)         State your assumptions of the content in registers and memory, before executing this instruction.         What will happen after executing this instruction? Answer: [ Write answer here ] 2(b)        Convert the following code fragment (in the C language) to assembly code. Explain steps.                                                                     [25 marks]    long test ( long a, long b, long c ) {        long t; if (a>b)...

  • Convert the following C fragment to equivalent MIPS assembly language. Assume that the variables a, b,...

    Convert the following C fragment to equivalent MIPS assembly language. Assume that the variables a, b, c, d, i and x are assigened to registers $t1, $t2, $t3, $t4, $s0 and $s1 respectively. Assume that the base address of the array A and B is in register $a0 and $a1 respectively. if (a > 0)            b = a + 10;            else                b = a - 10;

  • Convert the following C/C++ fragment into equivalent MIPS assembly language. Assume that the variables a, b,...

    Convert the following C/C++ fragment into equivalent MIPS assembly language. Assume that the variables a, b, c, d, i and x are assigned to registers $t1, $t2, $t3, $t4, $s0 and $s1 respectively. if ((a<b && (c == 0) d = 1;

  • Convert the following c code into instructions MIPS Assembly language. Assume a associated with $s0, i...

    Convert the following c code into instructions MIPS Assembly language. Assume a associated with $s0, i with $s1, and j with $s2. if( i < 10) {      if( j < 10)      { a = 0; }      else      { a = 1;} } else {      a = 2; }

  • a) Write the following C function in Assembly. You must follow the System V 64-bit calling...

    a) Write the following C function in Assembly. You must follow the System V 64-bit calling convention and use AT&T Syntax notation. long fibonacci (long n) { if (n == 0) return 0; else if (n == 1) return 1; else return (fibonacci (n - 1) + fibonacci (n - 2)); } b) The Windows x86-64 calling convention passes function parameters in the registers RCX, RDX, R8 and R9 and returns values on register RAX. Caller saved registers are: RAX,...

  • C++ READ CODE: 8. Below is a code fragment; assume x is an integer with the...

    C++ READ CODE: 8. Below is a code fragment; assume x is an integer with the value 40 at the start of the code fragment. Execute each code fragment and show the output below that code fragment. if (x 25) if (x 0) x=x*2; x=x+1; else ( x1i cout < xi

  • 3. Convert the following C code to assembly. Assume a, b, and c are in main...

    3. Convert the following C code to assembly. Assume a, b, and c are in main memory at addresses 1000, 1004, and 1008. if(a == 20) b=c+10; else b = c-14;

  • a) Write the following C function in Assembly. You must follow the System V 64-bit calling convention and use AT&T S...

    a) Write the following C function in Assembly. You must follow the System V 64-bit calling convention and use AT&T Syntax notation. Note: You cannot change the algorithm in any way so your assembly function must still be recursive. (20 points) long Catalan(long n) { long sum = 0; if (n == 0) return 1; for (int i = 0; i < n; i++) { sum += Catalan(i) * Catalan(n - i - 1); } return sum; } b) The...

  • 39. Rewrite the following C code segment in x86 (assume bs kebx) x86 switch (b) case...

    39. Rewrite the following C code segment in x86 (assume bs kebx) x86 switch (b) case 1 case 2: case 3: default: return Walpha" return "beta" return gamma" return "delta" 40. Does the following function definition qualfy as a leaf function? Why or why not? int quadratic(int x, int a, int b, int c) return a square (x) b 41. Assuming the GCC calling conventions are being used, what instructions always start the prolog of a function? 42. Assuming the...

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