MASM StrCmp 未定义?

发布于 2024-08-27 11:51:37 字数 1153 浏览 10 评论 0原文

如果我尝试汇编以下代码,则会收到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北笙凉宸 2024-09-03 11:51:38

您没有提到调用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文