MASM StrCmp 未定义?
如果我尝试汇编以下代码,则会收到 A2006 错误(错误 A2006:未定义符号:StrCmp)。
这是我的代码:
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\stdlib.lib
includelib \masm32\lib\user32.lib
.data
YvanSoftware db "(c) YvanSoftware - ALL RIGHTS RESERVED", 13 ,10 ,0
EnterYourName db "Please enter your name: ", 0
CRLF db 13,10,0
TheHolyMan db "Yvan", 0
Seriously db "Seriously? You're the MAN!", 13,10,0
LoserName db "What a loser name.", 13,10
.data?
buffer db 100 dup(?)
.code
start:
invoke StdOut,addr YvanSoftware
invoke StdOut, addr EnterYourName
invoke StdIn, addr buffer, 100
invoke StdOut, addr CRLF
invoke StrCmp,addr buffer, addr TheHolyMan ;error fires here
je HolyMan
IfNotHolyMan:
invoke StdOut, addr LoserName
jmp EndIfHolyMan
HolyMan:
invoke StdOut, addr Seriously
jmp EndIfHolyMan
EndIfHolyMan:
invoke ExitProcess,0
END start
我在汇编方面完全是个菜鸟,我正在努力学习它。 ;)
伊万
If I try to assemble the following code, I get a A2006 error ( error A2006: undefined symbol : StrCmp).
Here's my code:
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\stdlib.lib
includelib \masm32\lib\user32.lib
.data
YvanSoftware db "(c) YvanSoftware - ALL RIGHTS RESERVED", 13 ,10 ,0
EnterYourName db "Please enter your name: ", 0
CRLF db 13,10,0
TheHolyMan db "Yvan", 0
Seriously db "Seriously? You're the MAN!", 13,10,0
LoserName db "What a loser name.", 13,10
.data?
buffer db 100 dup(?)
.code
start:
invoke StdOut,addr YvanSoftware
invoke StdOut, addr EnterYourName
invoke StdIn, addr buffer, 100
invoke StdOut, addr CRLF
invoke StrCmp,addr buffer, addr TheHolyMan ;error fires here
je HolyMan
IfNotHolyMan:
invoke StdOut, addr LoserName
jmp EndIfHolyMan
HolyMan:
invoke StdOut, addr Seriously
jmp EndIfHolyMan
EndIfHolyMan:
invoke ExitProcess,0
END start
I'm a complete n00b at assembler, and I'm trying to learn it. ;)
Yvan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有提到调用 StdOut 时的任何错误,因此我假设这个可以组装。在这种情况下,错误应该与它所说的完全一样:在您列出的包含文件中无法识别 StrCmp。因此,只需确保您的包含之一实际上定义了 StrCmp(并且由于我不记得 MASM 默认为什么模式,因此为了安全起见,请尊重大小写)。
由于您使用的是 stdcall,因此您的调用将生成对 _StrCmp@8 之类的外部引用(@8 因为有两个参数,每个参数为 4 个字节)。因此,您还需要在 includelib 库之一中存在此修饰名称。但这不是您所看到的问题,因为此错误是masm 错误而不是链接器错误。
You do not mention any error on the invoke StdOut, so I assume this one assembles. In this case, the error should be exactly what it says: StrCmp is not recognized in the include files you listed. So just make sure one of your includes actually defines StrCmp (and since I don't remember what mode MASM defaults to, respect case sensitivy to be on the safe side).
Since You are using stdcall, your invoke will gen an external reference to something like _StrCmp@8 (@8 because there are two parms, each being 4 bytes). So you will also need to have this decorated name present in one of the includelib libs. This is not the problem you are seeing though, as this error is a masm one rather than a linker one.