CSC 325         Homework 1

 

Notice that

 

     2x2 - 6x + 5 = (2x - 6)x + 5

                 = (2x + (-6))x + 5

 

The computations required to calculate this are

 

          mov  ax, 0         ;ax = 0

          add  ax, 2         ;ax = 2

          imul x             ;ax = 2x

          add  ax, -6        ;ax = 2x - 6

          imul x             ;ax = (2x - 6)x

          add  ax, 5         ;ax = (2x - 6)x + 5

 

Finish the program poly.asm and store the program in your CSC325 account.

 

Then write a program quad.asm that allows the user to input a, b, c, and x and then calculates and displays the value of ax2 + bx + c.  You can use the file QUAD.txt as a template to solve this problem.  Quad.txt has all the input and output needed, you just have to write the assembly code to do the math.  Your final answer should be stored in the variable sum.