如何正确包含 .asm 文件?
How I can include .asm file properly?
在大学学习汇编时,遇到了以下问题:
我有 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
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
如何正确包含文件?
解法:
我只是编译错误
ml /c /coff main.asm
ml /c /coff module.asm
link /subsystem:console main.obj module.obj
在大学学习汇编时,遇到了以下问题:
我有 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
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
如何正确包含文件?
解法:
我只是编译错误
ml /c /coff main.asm
ml /c /coff module.asm
link /subsystem:console main.obj module.obj