如何正确包含.ASM文件?

发布于 2025-01-26 12:53:28 字数 1358 浏览 5 评论 0原文

在大学学习汇编器时,我遇到了以下问题:

我有3个文件(所有文件都过于简单,它们更大):

main.asm

.586
.model flat, stdcall
option casemap :none

include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include module.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.data
TextBuf db 64 dup(?)
Caption db "Test caption", 0
value1 db 25

.code
main:

call StrHex_MY
invoke MessageBoxA, 0, ADDR TextBuf, ADDR Caption, 0

invoke ExitProcess, 0
end main

< strong> module.asm

.586
.model flat, c
.code

StrHex_MY proc
xor eax, eax
StrHex_MY endp

end

module.inc

EXTERN StrHex_MY : proc

在尝试编译它后,我遇到了错误:

C:\SystemProgramming\lab2copy>ml.exe /c /coff main.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: main.asm

C:\SystemProgramming\lab2copy>link.exe /subsystem:console main.obj
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

main.obj : error LNK2001: unresolved external symbol _StrHex_MY
main.exe : fatal error LNK1120: 1 unresolved externals

如何正确包含文件?

When studying assembler at the university, I encountered the following problem:

I have 3 files (all of them oversimplified, they were much bigger):

main.asm

.586
.model flat, stdcall
option casemap :none

include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
include module.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.data
TextBuf db 64 dup(?)
Caption db "Test caption", 0
value1 db 25

.code
main:

call StrHex_MY
invoke MessageBoxA, 0, ADDR TextBuf, ADDR Caption, 0

invoke ExitProcess, 0
end main

module.asm

.586
.model flat, c
.code

StrHex_MY proc
xor eax, eax
StrHex_MY endp

end

module.inc

EXTERN StrHex_MY : proc

And after trying to compile it I got error:

C:\SystemProgramming\lab2copy>ml.exe /c /coff main.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: main.asm

C:\SystemProgramming\lab2copy>link.exe /subsystem:console main.obj
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

main.obj : error LNK2001: unresolved external symbol _StrHex_MY
main.exe : fatal error LNK1120: 1 unresolved externals

How I can include file properly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

朱染 2025-02-02 12:53:28

解决方案:

我只是在编译错误

ml /c /coff main.asm
ml /c /coff module.asm
link /subsystem:console main.obj module.obj

Solution:

I just was compiling it incorrectly

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