Write a program that will read in 3 16-bit integers: a, b and c and calculate
b2 - 4 a cand then print the answer. Please note that
c
is a reserved word in Assembler and cannot be used as a variable name. You are
required to print it out as opposed to using DumpRegs
. Using input is extra credit.
This will require you to know how to do multiplication in assembler as well as some basic input/output. The sample program below should help:
TITLE Multiply (Mult.asm) ;This program reads in and multipies 2 16-bit integers ; and then prints the result. ; Robert M. Siegfried INCLUDE Irvine32.inc .data Prompt BYTE "Enter a number ?", 0 Message BYTE "The product is: ", 0 x SDWORD ? y SDWORD ? Product SDWORD ? .code main PROC mov edx, OFFSET Prompt ; EDX must have the string's offset call WriteString ; Call the procedure to write a string call ReadInt ; Call the procedure to read an integer mov x, eax ; The integer is read into AL, AX or EAX mov edx, OFFSET Prompt ; Read another integer call WriteString call ReadInt mov y, eax mov eax, x ; AL AX or EAX must have the ; multiplicand cdq ; Clear the EDX register imul y ; One operand - the multiplier mov Product, eax ; The product is in AL, AX or EAX ; The lead bit (if it overflows) are ; in AH DX or EDX mov edx, OFFSET Message ; Print the answer call WriteString mov eax, Product ; The value must be in EAX call WriteInt exit main ENDP END main