尝试在 MASM32 中制作一个简单的程序 (LNK1120)
Trying to make a simple procedure in MASM32 (LNK1120)
; Library for I/O and other purposes
include c:\asmio\asm32.inc
includelib c:\asmio\asm32.lib
includelib c:\asmio\User32.lib ; SASM files for I/O
includelib c:\asmio\Kernel32.lib ; SASM files for I/O
input proto ; 0 parameters
; -------------------------------------------------------
.const ; Section to declare and initialize constants
NULL = 0
; -------------------------------------------------------
.data ; Section to declare and initialize variables
; number dword ? ;
read byte "Enter a number between 1-12: ", NULL
; -------------------------------------------------------
.code ; The actual code begins here: Main program
main proc ; Just like C++ this is the main program
invoke input
ret 0 ; need this line to return to caller
main endp ; End of the procedure main
end main ; End of the entire program
; -------------------------------------------------------
input proc
mov edx, OFFSET read
call WriteString
call ReadInt
ret
input endp
大家好!这是我尝试编写的第一个汇编代码。
我正在尝试创建一个程序,要求用户输入 1-12 之间的内容,然后将其写入 main 。我在 main 下面写了程序,在 main 上面写了原型,并在 main 中使用 invoke 调用了程序,但是 运行 出错了。
我的错误:
[08:46:41] Build started...
[08:46:42] Warning! Errors have occurred in the build:
program.o : error LNK2001: unresolved external symbol _input@0
C:\Users\yp0l0\AppData\Local\Temp\SASM\SASMprog.exe : fatal error LNK1120: 1 unresolved externals
有人看到我哪里错了吗?
这一行
end main
需要是源文件中的最后一行。由于目前它在 "input" 之前,输入函数被排除在程序集之外。
; Library for I/O and other purposes
include c:\asmio\asm32.inc
includelib c:\asmio\asm32.lib
includelib c:\asmio\User32.lib ; SASM files for I/O
includelib c:\asmio\Kernel32.lib ; SASM files for I/O
input proto ; 0 parameters
; -------------------------------------------------------
.const ; Section to declare and initialize constants
NULL = 0
; -------------------------------------------------------
.data ; Section to declare and initialize variables
; number dword ? ;
read byte "Enter a number between 1-12: ", NULL
; -------------------------------------------------------
.code ; The actual code begins here: Main program
main proc ; Just like C++ this is the main program
invoke input
ret 0 ; need this line to return to caller
main endp ; End of the procedure main
end main ; End of the entire program
; -------------------------------------------------------
input proc
mov edx, OFFSET read
call WriteString
call ReadInt
ret
input endp
大家好!这是我尝试编写的第一个汇编代码。
我正在尝试创建一个程序,要求用户输入 1-12 之间的内容,然后将其写入 main 。我在 main 下面写了程序,在 main 上面写了原型,并在 main 中使用 invoke 调用了程序,但是 运行 出错了。
我的错误:
[08:46:41] Build started...
[08:46:42] Warning! Errors have occurred in the build:
program.o : error LNK2001: unresolved external symbol _input@0
C:\Users\yp0l0\AppData\Local\Temp\SASM\SASMprog.exe : fatal error LNK1120: 1 unresolved externals
有人看到我哪里错了吗?
这一行
end main
需要是源文件中的最后一行。由于目前它在 "input" 之前,输入函数被排除在程序集之外。