I’m working on a project for class, and the professor wants us to use MASM instead of any other assembler. (I know thats is stupid, talk to him not me.) When I run ML.exe to compile my code, it crashes. Not the program I’m writing, but the assembler itself. What could possibly cause that? It’s running for a really long time before it goes, so maybe it’s an infinite loop of some sort.
Here’s my code:
.386
.MODEL FLAT
PUBLIC compute_b_proc
points EQU [ebp + 16]
bs EQU [ebp + 12]
n EQU [ebp + 10]
m EQU [ebp + 8]
.CODE
compute_b_proc PROC NEAR32
push ebpi
mov ebp, esp
mov ax, n
cmp ax, m
je base_case
mov ax, m
inc ax
pushd points
push n
push m
call compute_b_proc
push eax
fld DWORD PTR [esp + 8]
pop eax
mov ax, n
dec ax
pushd points
push n
push m
call compute_b_proc
push eax
fld DWORD PTR [esp + 4]
pop eax
fsubp
lea eax, points
mov ebx, n
shr ebx, 3
add eax, ebx
fild REAL4 PTR [eax + 4]
lea eax, points
mov ebx, m
shr ebx, 3
add ebx, 4
add eax, ebx
fild REAL4 PTR [eax]
fsubp
fdivp
pushd 0
fstp DWORD PTR [eax + 4]
pop eax
mov esp, ebp
pop ebp
ret 12
lea eax, points
mov ebx, n
shl ebx, 3
add eax, ebx
mov eax, DWORD PTR[eax]
mov esp, ebp
pop ebp
ret 12
compute_b_proc ENDP
END
MASM compiles other files fine. The error message is just “ML.exe has stopped working,” nothing else. I should note that I’m using MASM version 6.11. It’s what the professor provided.
It seems to be the floating point instructions that make it crash. I reinstalled MASM, but it’s still crashing on everything floating point.
I figured it out… sort of. My floating point instructions were incorrect. fsubp should have been fsub, fmulp should be fmul, etc. Why that crashed the compiler, I have no idea, but changing fixed the problem.