`Hey,
Note: Brother if you have any queries related the answer please do comment. I would be very happy to resolve all your queries.
; roots.asm segment .text global _roots _roots: enter 0,0 xor EAX,EAX fld qword[EBP+8] ; a fadd ST0 ; 2a fld qword[EBP+8] ; a,2a fld qword[EBP+24] ; c,a,2a fmulp ST1 ; ac,2a fadd ST0 ; 2ac,2a fadd st0 ; 4ac,2a fchs ; -4ac,2a fld qword[EBP+16] ; b,-4ac,2a fld qword[EBP+16] ; b,b,-4ac,2a fmulp ST1 ; b*b,-4ac,2a faddp ST1 ; b*b-4ac,2a ftst ; cmp (b*b-4ac),0 fstsw AX ; result of test in AX sahf ; store AH in flag reg jb no_real_roots ; jb tests the carry flag fsqrt ; sqrt(b*b-4ac),2a fld qword[EBP+16] ; b,sqrt(b*b-4ac),2a fchs ; -b,sqrt(b*b-4ac),2a fadd ST1 ; -b+sqrt(b*b-4ac),sqrt(b*b-4ac),2a fdiv ST2 ; -b+sqrt(b*b-4ac)/2a,sqrt(b*b-4ac),2a mov EAX,dword[EBP+32] ; EAX = -b+sqrt(b*b-4ac)/2a fstp qword[EAX] ; Store and pop fchs ; -sqrt(b*b-4ac),2a fld qword[EBP+16] ; b,-sqrt(b*b-4ac),2a fchs ; -b,-sqrt(b*b-4ac),2a faddp ST1 ; -b-sqrt(b*b-4ac),2a fdivrp ST1 ; -b-sqrt(b*b-4ac)/2a mov EAX,dword[EBP+36] ; EAX = -b-sqrt(b*b-4ac)/2a fstp qword[EAX] ; Store and pop mov EAX,1 ; 1 means real roots jmp short done no_real_roots: fchs ; Make b*b-4ac positive fsqrt ; sqrt(b*b-4ac),2a fld qword[EBP+16] ; b,sqrt(b*b-4ac),2a fchs ; -b,sqrt(b*b-4ac),2a fadd ST1 ; -b+sqrt(b*b-4ac),sqrt(b*b-4ac),2a fdiv ST2 ; -b+sqrt(b*b-4ac)/2a,sqrt(b*b-4ac),2a mov EAX,dword[EBP+32] ; EAX = -b+sqrt(b*b-4ac)/2a fstp qword[EAX] ; Store and pop fchs ; -sqrt(b*b-4ac),2a fld qword[EBP+16] ; b,-sqrt(b*b-4ac),2a fchs ; -b,-sqrt(b*b-4ac),2a faddp ST1 ; -b-sqrt(b*b-4ac),2a fdivrp ST1 ; -b-sqrt(b*b-4ac)/2a mov EAX,dword[EBP+36] ; EAX = -b-sqrt(b*b-4ac)/2a fstp qword[EAX] ; Store and pop sub EAX,EAX ; 0 means no real roots done: leave ret
Kindly revert for any queries
Thanks.
program in assembiy language x86 In assembly language using float point Quadratic Formula Prompt the user...
This is a question from Assembly Language for x86 7th Edition by Kip Irvine, but the solution is not there. Programming exercise 12.7 #2. The code must be in assembly language for Intel using Kip Irvine library. An example of the source code would be: INCLUDE Irvine32.inc .code main PROC mov ax,4000h mov bx,1000h mov cx,1500h sub ax,bx sub ax,cx call DumpRegs exit main ENDP END main Question: Write a procedure that receives a single-precision floating-point binary value and displays...
please answer this question with python. Write a program to solve the quadratic equation ax^2 + bx + c = 0 using the standard quadratic formula x = -b plusminus Squareroot b^2 - 4ac/2a or the alternative formula x = 2c/-b Squareroot b^2 - 4ac. Your program should accept values for the coefficients a, b, and c as input and produce the two roots of the equation as output. Your program should detect when the roots are imaginary, but need...
Question 4: Provide at least 4 test cases. Prompt the user to input 3 doubles, a, b and c. Which will represent the coefficients in the quadratic equation ax2 + bx + c = 0. Print out the solutions (if any) of the quadratic equation. If no root exists (this happens if a == 0, or b2 <4ac) print the message No real root. Sample input/ user entries shown in red Corresponding output Enter a, b and c which represent...
In Python. The two roots of a quadratic equation ax^2 + bx + c = 0 can be obtained using the following formula: r1 = (-b + sqrt(b^2 - 4ac) / (2a) and r2 = (-b - sqrt(b^2 - 4ac) / (2a) b^2 - 4ac is called the discriminant of the quadratic equation. If it is positive, the equation has two real roots. If it is zero, the equation has one root. If it is negative, the equation has no...
This is in python language Algebra: solve quadratic equations) The two roots of a quadratic equation, for example, 0, can be obtained using the following fomula: b 4ac is called the discriminant of the quadratic equation. If it is positive, the equation has two real roots. If it is zero, the equation has one root. If it is negative, the equation has no real roots. Write a program that prompts the user to enter values for a, b, and cand...
Use Python Programming. Design a class named Quadratic Equation for a quadratic equation ax + bx+c 0. The class contains: • The data fields a, b, and c that represent three coefficients. . An initializer for the arguments for a, b, and c. • Three getter methods for a, b, and c. • A method named get Discriminant() that returns the discriminant, which is b- 4ac The methods named getRoot 1() and getRoot 2() for returning the two roots of...
We are using the Kip Irvine Assembly Language for x86 Processors. The programming language is Assembly, and we are using visual studio community. Please specify any questions. Directions Declare an array of 60 uninitialized unsigned doubleword values. Create another array of 60 unsigned doublewords, initialized to ‘abcd’. Look at these arrays in the memory window and note how they are stored. (Intel architecture uses little - endian order) ATTEMPT ONLY IF YOU KNOW OTHERWISE I WILL DOWNVOTE.
Task 3 [35 marks] Write a MIPS program that does the following (in a correct, user-friendly way): Greets the user, states the purpose of the program Sequentially asks the user to provide integer coefficients A,B,C Calculates discriminant D of quadratic polynomial. (Hint: D = B2 – 4×A×C) Displays the calculated D value Checks (in this order) whether discriminant is: o D = 0? Then, displays: “Quadratic polynomial has a sole root.” o D > 0?...
write a C programming code for the following prompt. please use stucture concept and test if the code works perfectly. Project Description: In this project, you will write a program to calculate the roots of a quadratic equation. Structure concepts will be used in this project. Your program will prompt the user to enter the coefficients of a quadra coefficientsType. Then it will compute the roots of the quadratic equation and store the result in a structure variable of type...
In assembly language computer programming 1. create a 5 element array 2.prompt the user to enter 5 numbers to fill the array 3. exchange the number at position 1 with the number at position 4 of the array. (Don't forget that array positions are counted from zero, in our case 5 element array positions are counted 0,1,2,3,4.) 4.Display the array numbers 1 and 4 to show that you did the exchange correctly. Show a message like "The number at position...