I'm in the process of creating an assembly program that calculates the roots of a quadratic equation. I was able to find one root, but the formatting is off.
Here is the code:
INCLUDE Irvine32.inc
INCLUDE macros.inc
.data
msg1 byte "Result: ", 0
msg2 byte "With precision: ", 0
msg3 byte "a", 0
a real8 ?
b real8 ?
cc real8 ?
two real8 2.0
four real8 4.0
ten dword 10
.code
main PROC
finit
mWrite "Enter coefficient (a): "
call ReadFloat
fstp a
mWrite "Enter coefficient (b): "
call ReadFloat
fstp b
mWrite "Enter coefficient (c): "
call ReadFloat
fstp cc
fld b
fmul b
fchs
fst b
call Crlf
fld four
fmul a
fmul cc
fchs
fsub b
fsqrt
fst four
;call WriteFloat
call Crlf
fld b
fchs
fsqrt
fchs
fadd four
fst b
fld two
fmul a
fst two
fld b
fdiv two
mWrite "Root: "
call WriteFloat
;call showfpustack
exit
main ENDP
end main
The result I'm getting is correct. However, I want to show it as -0.35425 (5 floating point precision). How can I format the output? I tried dividing the value by 10 which should work in theory. I would appreciate any help!