【发布时间】:2024-04-21 16:25:01
【问题描述】:
我正在做一个课堂项目,教授希望我们使用 MASM 而不是任何其他汇编程序。 (我知道那很愚蠢,和他说话而不是我。)当我运行 ML.exe 来编译我的代码时,它崩溃了。不是我正在编写的程序,而是汇编程序本身。什么可能导致这种情况?它在运行之前运行了很长时间,所以它可能是某种无限循环。
这是我的代码:
.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 可以很好地编译其他文件。错误消息只是“ML.exe 已停止工作”,仅此而已。我应该注意我使用的是 MASM 6.11 版。这是教授提供的。
似乎是浮点指令导致它崩溃。我重新安装了 MASM,但它仍然在所有浮点数上崩溃。
【问题讨论】:
-
你在一个小而简单的文件上使用了 masm 来确定它是 masm 本身还是 masm+你的代码?如果 masm+你的代码,你已经砍掉了代码块或者从零开始慢慢添加东西,对吗?
-
听起来你安装的 masm 可能是错误的——对我来说根本没有崩溃(并且确实指出了你的代码中的一些错误,例如在几次推送中缺少指定的大小,以及
ebpi(显然是 ebp)和base_case是未定义符号的事实。 -
这里很有可能“崩溃”实际上是一条错误消息。我们不能回头看,当您发布您所看到的内容时,您只能从 SO 之类的网站获得帮助。引用 exact 错误消息。
-
MASM 可以很好地编译其他文件。错误消息只是“ML.exe 已停止工作”,仅此而已。我应该注意到我使用的是 MASM 6.11 版。这是教授提供的。
标签: assembly compilation linker masm ml