Question

In: Computer Science

write mips assembly mips assembly (x+a) (bx^2+cx+d) using the pesedo- code with loop ,program should claclute...

write mips assembly

mips assembly (x+a) (bx^2+cx+d) using the pesedo- code with loop ,program should claclute six T[i] and display aproper message about roots .the the program should store all T[i] as memory array


a = [1, 1, 1, 1, 1, 1];
b = [1, 2, 4, 8, 16, 32];
c = [-6, -4, -2, 2, 4, 6];
d = [-1, -3, -5, -7, -9, -11];

for (i=0 ; i<=6; i++) {
T[i] =-4 *b [i] * d[i] +c[i] * c[i];
if (T[i] <0)
display "tow roots are imaginary";
else

display "tow roots are real ";
}

Solutions

Expert Solution

.LC0:

.string "tow roots are imaginary"

.LC1:

.string "tow roots are real "

main:

push rbp

mov rbp, rsp

sub rsp, 160

mov DWORD PTR [rbp-64], 1

mov DWORD PTR [rbp-60], 1

mov DWORD PTR [rbp-56], 1

mov DWORD PTR [rbp-52], 1

mov DWORD PTR [rbp-48], 1

mov DWORD PTR [rbp-44], 1

mov DWORD PTR [rbp-96], 1

mov DWORD PTR [rbp-92], 2

mov DWORD PTR [rbp-88], 4

mov DWORD PTR [rbp-84], 8

mov DWORD PTR [rbp-80], 16

mov DWORD PTR [rbp-76], 32

mov DWORD PTR [rbp-128], -6

mov DWORD PTR [rbp-124], -4

mov DWORD PTR [rbp-120], -2

mov DWORD PTR [rbp-116], 2

mov DWORD PTR [rbp-112], 4

mov DWORD PTR [rbp-108], 6

mov DWORD PTR [rbp-160], -1

mov DWORD PTR [rbp-156], -3

mov DWORD PTR [rbp-152], -5

mov DWORD PTR [rbp-148], -7

mov DWORD PTR [rbp-144], -9

mov DWORD PTR [rbp-140], -11

mov DWORD PTR [rbp-4], 0

.L5:

cmp DWORD PTR [rbp-4], 6

jg .L2

mov eax, DWORD PTR [rbp-4]

cdqe

mov edx, DWORD PTR [rbp-96+rax*4]

mov eax, DWORD PTR [rbp-4]

cdqe

mov eax, DWORD PTR [rbp-160+rax*4]

imul edx, eax

mov eax, 0

sub eax, edx

sal eax, 2

mov ecx, eax

mov eax, DWORD PTR [rbp-4]

cdqe

mov edx, DWORD PTR [rbp-128+rax*4]

mov eax, DWORD PTR [rbp-4]

cdqe

mov eax, DWORD PTR [rbp-128+rax*4]

imul eax, edx

lea edx, [rcx+rax]

mov eax, DWORD PTR [rbp-4]

cdqe

mov DWORD PTR [rbp-32+rax*4], edx

mov eax, DWORD PTR [rbp-4]

cdqe

mov eax, DWORD PTR [rbp-32+rax*4]

test eax, eax

jns .L3

mov edi, OFFSET FLAT:.LC0

mov eax, 0

call printf

jmp .L4

.L3:

mov edi, OFFSET FLAT:.LC1

mov eax, 0

call printf

.L4:

add DWORD PTR [rbp-4], 1

jmp .L5

.L2:

mov eax, 0

leave

ret


Related Solutions

A cubic polynomial is of the form: f(x) = Ax^3 + Bx^2 + Cx + D...
A cubic polynomial is of the form: f(x) = Ax^3 + Bx^2 + Cx + D    A root of the polynomial is a value, x, such that f(x)=0.   Write a program that takes in the coefficients of a cubic polynomial: A, B, C, and D. The program finds and reports all three roots of the polynomial. Hint: First use bisection method to determine a single root of the polynomial. Then divide the polynomial by its factor to come up...
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x +...
Write a MIPS assembly language program that implements the following pseudo-code operation: result = x + y – z + A[j] x and y should be in reserved memory words using the .word directive and labeled as x and y. Initialize x=10 and y=200. Read in z from the console. Input the value -8. This is the value for z, not for –z. Store this value in memory with the label z. To begin, you could just initialize z to...
The curves of the quadratic and cubic functions are f(x)=2x-x^2 and g(x)= ax^3 +bx^2+cx+d. where a,b,c,d...
The curves of the quadratic and cubic functions are f(x)=2x-x^2 and g(x)= ax^3 +bx^2+cx+d. where a,b,c,d ER, intersect at 2 points P and Q. These points are also two points of tangency for the two tangent lines drawn from point A(2,9) upon the parobala. The graph of the cubic function has a y-intercept at (0,-1) and an x intercept at (-4,0). What is the standard equation of the tangent line AP.
The curves of the quadratic and cubic functions are f(x)=2x-x^2 and g(x)= ax^3 +bx^2+cx+d. where a,b,c,d...
The curves of the quadratic and cubic functions are f(x)=2x-x^2 and g(x)= ax^3 +bx^2+cx+d. where a,b,c,d ER, intersect at 2 points P and Q. These points are also two points of tangency for the two tangent lines drawn from point A(2,9) upon the parobala. The graph of the cubic function has a y-intercept at (0,-1) and an x intercept at (-4,0). What is the value of the coefficient "b" in the equation of the given cubic function.
Write a mips assembly code program that ask the user to enter an integer value, and...
Write a mips assembly code program that ask the user to enter an integer value, and then print the result of doubling that number.
This is to be done with MIPS assembly language. Write MIPS code which is equivalent to...
This is to be done with MIPS assembly language. Write MIPS code which is equivalent to the follow java program: int day = (int)(Math.random() * 7); switch (day) { case 1: System.out.println(“Monday”); break case 2: System.out.println(“Tuesday”); break case 3: System.out.println(“Wednesday”); break case 4: System.out.println(“Thursday”); break case 5: System.out.println(“Friday”); break case 6: System.out.println(“Saturday”); break case 0: System.out.println(“Sunday”); break }
Write assembly code to implement the expression A = (B + C - D) x (D...
Write assembly code to implement the expression A = (B + C - D) x (D + E x F) on three-, two-, one-, and zero-address machines (do not change the values of the operands). Refer to Chapter 5 Slides 25-28 for the syntax.
Write an assembly code in MIPS program that can read 3 numbers from the user and...
Write an assembly code in MIPS program that can read 3 numbers from the user and print the following: a. The summation b. The average c. The minimum d. The maximum e. Print the values between the minimum and maximum f. Write comments to explain each line in your code -look at Fibonacci code- (no comments mean zero for the assignment ) use MARS MIPS .
[Procedures] Write a main program which sets the registers BX and CX and calls a procedure...
[Procedures] Write a main program which sets the registers BX and CX and calls a procedure Add-Two. The procedure Add-Two adds the values in registers BX and CX and returns the output (which is the sum) in AX. Single step through the program, displaying the value of the stack pointer so that you understand how the call and return are implemented.
MIPS assembly code: procedure:                   addi $s0,$zero,0 loop:                   slt
MIPS assembly code: procedure:                   addi $s0,$zero,0 loop:                   slti $t1, $s0, 7                   beq $t1, $zero, exit                   addi $s0,$s0,1                   j loop exit:                   add $v0, $zero, $s0                   jr $ra       What is the corresponding high-level programming language code? Write a code in your preferred language. What is the result? (5 pts) Code: int add(int a, int b) {       return a+b; } int sub(int a, int b) {      ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT