I'm getting a crash that I just don't understand. Which is understandable because I really don't know much about Assembly yet. I'm using MASM on Visual Studio 2013.
All of the code is executing properly (I think. I have print statements that show calculations have proceeded just fine). But when things get to the end of the program, it just crashes: unhandled exception 5880, program.exe has encountered a breakpoint.
I feel like it means that I should have cleaned up the FPU's register stack.
So I did. I tossed in a FSTP toward an uninitialized variable but that didn't do anything. Or rather, it didn't resolve anything. I did a bit more reading and saw that if there are unhandled exceptions with the FPU because other, non-FPU instructions were executed that could cause funkiness. So I tried throwing an fwait
to give it time to handle its business. It didn't handle junk.
I'm sure, once again, there is something simple I'm missing. Which is why I'd very much appreciate someone pointing it out to me.
Here is my code, if that'll help.
TITLE Circular Area.asm
INCLUDE Irvine32.inc
.data
prompt BYTE "Please input the radius of the cirle whose area you wish to calculate: " , 0
answer BYTE "The area of the circle is: " , 0
debug BYTE "I'm at least getting this far. So the FPU isn't bugged." , 0
.DATA?
radius DWORD ?
rsquared DWORD ?
answerF REAL8 ?
.code
FINIT
main PROC
mov EAX, 0
mov EDX, OFFSET prompt
call WriteString
call ReadDec
mov radius, EAX
mul radius
mov rsquared, EAX
FLDPI
FIMUL rsquared
mov EDX, OFFSET answer
call WriteString
call WriteFloat
fwait
main ENDP
END main
You're not telling the OS that you want the execution of your application to end. Since this seems to be a Windows application, you should use the ExitProcess
function:
invoke ExitProcess,0
Note that you'll need to include kernel32.inc
and link against kernel32.lib
, if you're not already doing so.