Question

Q1 [15] Convert the following C code to LEG. Assume the following variable/register assignments: Base of A i X19 X20 int main
convert C to LEGv8

(an example given below)
for (X13 0; X13 < X14; X13++) { X10 X15 X9 } ADDI X13, XZR, #0 //X13 0 Loop: SUBS XZR, X13, X14 //compare X13 and X14 //if X1
0 0
Add a comment Improve this question Transcribed image text
Answer #1

  mov DWORD PTR [rbp-20], 0
jmp .L2
.L3:
mov eax, DWORD PTR [rbp-20]
lea ebx, [rax+2]
mov eax, DWORD PTR [rbp-20]
add eax, 1
mov eax, eax
mov rdx, QWORD PTR [rbp-80+rax*8]
mov eax, DWORD PTR [rbp-20]
mov rax, QWORD PTR [rbp-80+rax*8]
mov rsi, rdx
mov rdi, rax
mov eax, 0
call myFunction
cdqe
mov edx, ebx
mov QWORD PTR [rbp-80+rdx*8], rax
add DWORD PTR [rbp-20], 1
.L2:
cmp DWORD PTR [rbp-20], 3
jbe .L3
mov eax, 0
add rsp, 72
pop rbx
pop rbp
ret

Add a comment
Know the answer?
Add Answer to:
convert C to LEGv8 (an example given below) Q1 [15] Convert the following C code to...
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
  • 19. (4 points) Convert the following C function (a leaf procedure) to an LEGv8 assembly subroutine....

    19. (4 points) Convert the following C function (a leaf procedure) to an LEGv8 assembly subroutine. Make sure that you follow the LEGv8 calling conventions. long long int func (long long int a, long long int b) long long int 0: long long int s 0: while (s < b) return k;

  • i need help fixing my code. here is the assignment: Make a class that contains the...

    i need help fixing my code. here is the assignment: Make a class that contains the following functions: isLong, isDouble, stringToLong, and stringToDouble. Each receives a string and returns the appropriate type (bool, bool, long, and double).During the rest of the semester you will paste this class into your programs and will no longer use any of the "standard" c# functions to convert strings to numbers. here is my code. it works for the long method but not the double:...

  • C++ problem where should I do overflow part? in this code do not write a new...

    C++ problem where should I do overflow part? in this code do not write a new code for me please /////////////////// // this program read two number from the user // and display the sum of the number #include <iostream> #include <string> using namespace std; const int MAX_DIGITS = 10; //10 digits void input_number(char num[MAX_DIGITS]); void output_number(char num[MAX_DIGITS]); void add(char num1[MAX_DIGITS], char num2[MAX_DIGITS], char result[MAX_DIGITS], int &base); int main() { // declare the array = {'0'} char num1[MAX_DIGITS] ={'0'}; char...

  • answer in c++ Using the table below, complete the C++ code to write the function prototype...

    answer in c++ Using the table below, complete the C++ code to write the function prototype statement, and the void function header. The void function should receive three double variables: the first two by value and the last one by reference. Name the formal parameters num1, num2 and answer. The function should divide the num1 variable by the num2 variable and then store the result in the answer variable. Name the function calcQuotient. Also write an appropriate function prototype for...

  • Can Anyone help me to convert Below code to C++! Thanks For example, in C++, the...

    Can Anyone help me to convert Below code to C++! Thanks For example, in C++, the function headers would be the following: class MaxHeap { vector<int> data; public: MaxHeap() { // ... } int size() { // ... } int maxLookup() { // ... } void extractMax() { // ... } void insert(int data) { // ... } void remove(int index) { // ... } }; ======================== import java.util.Arrays; import java.util.Scanner; public class MaxHeap { Integer[] a; int size; //...

  • How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++...

    How can I convert the following C code to MIPS Assembly? +++++++++++++++++++++++++++++++++ MIPS main program ++++++++++++++++++++++++++++++++ .data # Defines variable section of an assembly routine. array: .word x, x, x, x, x, x, x, x, x, x # Define a variable named array as a word (integer) array # with 10 unsorted integer numbers of your own. # After your program has run, the integers in this array # should be sorted. .text # Defines the start of the code...

  • Given the following C Code segment convert it to ARM assembly. Assume the following register assignment...

    Given the following C Code segment convert it to ARM assembly. Assume the following register assignment have been made before your section of code begins. C Variable Register assignment r1 y r2 r3 r10 j r11 int x=0, y=0, z=0; int main() { for (int i = 0; i<10; i++) for (int j 0; j < 20; j++) if (i* j > 100) X++; if (i j >= 15) y++; + فہه Z = X + y; }

  • I want c++ code for employee payslip calculation using switch statement convert this code to switch...

    I want c++ code for employee payslip calculation using switch statement convert this code to switch statement also, use for loop ___________________________________________________________________________ #include using namespace std; int main() {char empname[222]; float basicSalary, h_r_a, DearnessAllow, tax, netSalary; int e_id; cout<<"\nEmployee Name :"; cin>>empname; cout<<"\nEmployee Id :"; cin>>e_id; cout << "Enter Basic Salary : "; cin >> basicSalary; DearnessAllow = 0.30 * basicSalary; h_r_a= 800; tax = 0.10 * basicSalary; netSalary = basicSalary + DearnessAllow + h_r_a - tax; cout<<"\nEmployee Id              :...

  • Convert into pseudo-code for below code =============================== class Main {    public static void main(String args[])...

    Convert into pseudo-code for below code =============================== class Main {    public static void main(String args[])    {        Scanner s=new Scanner(System.in);        ScoresCircularDoubleLL score=new ScoresCircularDoubleLL();        while(true)        {            System.out.println("1--->Enter a number\n-1--->exit");            System.out.print("Enter your choice:");            int choice=s.nextInt();            if(choice!=-1)            {                System.out.print("Enter the score:");                int number=s.nextInt();                GameEntry entry=new GameEntry(number);   ...

  • Convert the TreeArray C++ source code(posted below) into a BinaryTree, using this TreeNode definition: class TreeNode<T>...

    Convert the TreeArray C++ source code(posted below) into a BinaryTree, using this TreeNode definition: class TreeNode<T>       T data       TreeNode<T> left       TreeNode<T> right Since this TreeNode is a generic Template, use any data file we've used this quarter to store the data in the BinaryTree. To do this will likely require writing a compare function or operator. Hint: Think LEFT if the index is calculate (2n+1) and RIGHT if index is (2n+2). Source code: #include<iostream> using namespace std;...

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