Question

In: Computer Science

Must use AT&T x64/GNU Assembly syntax. Write an assembly language program that reads in two integers,...

Must use AT&T x64/GNU Assembly syntax.

Write an assembly language program that reads in two integers, A and B, and uses them to compute the following expressions. You must use the same values for A and B throughout all three expressions.

1) A * 5

2) (A + B) - (A / B)

3) (A - B) + (A * B)

Solutions

Expert Solution

The given first expression is:

1) A*5

Let X=A*5

Therfore, GNU Assembly syntax for the above expession can be written as:

MOV(A, eax);

MUL(5, eax:edx);

Mov(edx, X);

____________________________________________________________________________________________

The given second expression is:

2) (A+B)-(A/B)

Let X: (A+B)-(A/B)

Therfore, GNU Assembly syntax for the above expession can be written as:

MOV(A, eax);

ADD(B, eax);

MOV(eax, Temp1);

MOV(A, eax);

DIV(B, eax);

MOV(eax, Temp2);

MOV(Temp1, eax);

SUB(Temp2, eax);

MOV(eax, x);

____________________________________________________________________________________________

The given third expression is:

3) (A-B)+(A*B)

Let X: (A-B)+(A*B)

Therfore, GNU Assembly syntax for the above expession can be written as:

MOV(A, eax);

SUB(B, eax);

MOV(eax, Temp1);

MOV(A,eax);

MUL(B, eax);

MOV(eax, Temp2);

MOV(Temp1, eax);

ADD(Temp2, eax);

MOV(eax, x)

____________________________________________________________________________________________

Here, we have assigned 32 bit signed integer value to register eax in all the expressions.


Related Solutions

AT&T x64/GNU Assembly syntax only please Write an assembly language program which either hardcodes or reads...
AT&T x64/GNU Assembly syntax only please Write an assembly language program which either hardcodes or reads in the lengths of the sides of a triangle, and outputs a truthy value (1, “true”, “yes”, and others) indicating whether the triangle is a valid one or not (0, “false”, “no”, etc). A triangle is valid if the sum of each pair of sides is greater than the unpaired side. Meaning if a, b, c are the three sides of a triangle, then...
**IN AT&T ASSEMBLY LANG** Write an assembly language program which either hardcodes or reads in two...
**IN AT&T ASSEMBLY LANG** Write an assembly language program which either hardcodes or reads in two integers, A and B, and uses them to compute the following expressions. You must use the same values for A and B throughout all three expressions. A * 5 (A + B) - (A / B) (A - B) + (A * B)
1. Write an assembly language program that prompts the user for and reads four integers (x1,...
1. Write an assembly language program that prompts the user for and reads four integers (x1, y1, x2, y2) which represent the coordinates of two points. Make sure you keep track of which number is which. 2. Treat the line between the points as the radius of a sphere and compute the surface area of the sphere. Print the output with a label, such as “The surface area of the sphere is: …”. Hint: The distance between the points is...
Write a mips assembly language program to ask the user to enter two integers A and...
Write a mips assembly language program to ask the user to enter two integers A and B and then display the result of computing the expression: A + 2B - 5.
Use MIPS assembly language program to swap two of the integers in an integer array. The...
Use MIPS assembly language program to swap two of the integers in an integer array. The program should include the Swap function to swap the integers and the main function to call the Swap function. The main function should: • Pass the starting address of the array in $a0. • Pass the indices of the two elements to swap in $a1 and $a2. • Preserve (i.e. push onto the stack) any T registers that it uses. • Call the Swap...
Assignment Description: Write a MIPS assembly language program that adds the following two integers and displays...
Assignment Description: Write a MIPS assembly language program that adds the following two integers and displays the sum and the difference. In the .data section, define two variables num1 and num2 both words. Initialize num1 to 92413 10 and num2 to D4B 16 (use 0xD4B to initialize, Note that D4B is a hexadecimal number). Your main procedure/function should load the values of num1 and num2 into two temporary registers, and display them on the console window. Then add the values...
Write a RARS assembly language program to solve the following: For a set of integers stored...
Write a RARS assembly language program to solve the following: For a set of integers stored in an array, calculate the sum of the positive numbers and the sum of the negative numbers, storing the results into memory. In the data segment of the program, define an array consisting of 25 integers (words) that are a mix of positive and negative values. You can select any values you wish but try to create a balance of positive and negative numbers....
IN C LANGUAGE This program reads a threshold, a size, and an array of integers. The...
IN C LANGUAGE This program reads a threshold, a size, and an array of integers. The program then calls the foo function. The function will modify the array x of size n by doubling any values in x that are less than the threshold. The function will count how many values were changed and how many were not changed via two reference parameters. The function signature is: void foo(int n, int x[], int threshold, int *pChanged, int *pUnchanged); The function...
Write an assembly language program that reads move review information from a text file and reports...
Write an assembly language program that reads move review information from a text file and reports the overall scores for each movie as well as identifying the movie with the highest total score. There are four movie reviewers numbered from 1 to 4. They are submitting reviews for five movies, identified by the letters from “A” through “E”. Reviews are reported by using the letter identifying the movie, the review rating, which is a number from 0 to 100, and...
Use C language Write a program that reads in a series of lines of input character...
Use C language Write a program that reads in a series of lines of input character by character (using getchar()). The first line of the input contains an integer which specifies the number of remaining lines of input, each of which contains a floating point number. The integer value on the first line can be read with scanf(), but all of the following lines can only be read with getchar(). Each line after the first contains a single floating point...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT