.386 .model flat,stdcall option casemap:none include \masm32\include\masm32.inc include \masm32\include\kernel32.inc include \masm32\include\msvcrt.inc includelib \masm32\lib\masm32.lib includelib \masm32\lib\kernel32.lib includelib \masm32\lib\msvcrt.lib .DATA FOUR dq 4 WelcomeMes db 'Type a,b,c:',0ah,0dh,0 Query db '%lf %lf %lf',0 ANo_Roots db 'Expression has no roots!\n',0ah,0dh,0 AOne_Root db 'Expression has one root! %lf',0ah,0dh,0 ATwo_Roots db 'Expression has two roots! %lf, %lf',0ah,0dh,0 _A dq ? _B dq ? _C dq ? _D dq ? _H dw ? _X1 dw ? _x2 dw ? .CODE START: finit push offset WelcomeMes call crt_printf push offset _C push offset _B push offset _A push offset Query call crt_scanf ;D = b * b + 4 * a * c fld _B fld _B fmul fstp _D fild FOUR fld _A fld _C fmul fmul fld _D fadd fldz fcom fstsw ax sahf fsqrt fstp _D ; ST(0) = 0, ST(1) = D je ONE_ROOT; ST(0) == ST(1) == 0 jl NO_ROOTS jg TWO_ROOTS ONE_ROOT: fld _B fld _B fld _B fmul fsub fld _D fadd fstp qword ptr [esp] push offset AOne_Root call crt_printf jmp END_POINT TWO_ROOTS: fld _B fld _B fld _B fmul fsub fld _D fadd fstp qword ptr [esp] fld _B fld _B fld _B fmul fsub fld _D fsub fstp qword ptr [esp + 8] push offset ATwo_Roots call crt_printf jmp END_POINT NO_ROOTS: push offset ANo_Roots call crt_printf jmp END_POINT END_POINT: push 0 call ExitProcess END START
Comments