我正在使用visual c++ express编译器来编译asm32:
; Example assembly language program -- adds 158 to number in memory
; Author: R. Detmer
; Date: 1/2008
.586
.MODEL FLAT
.STACK 4096 ; reserve 4096-byte stack
.DATA ; reserve storage for data
number DWORD -105
sum DWORD ?
.CODE ; start of main program code
main PROC
mov eax, number ; first number to EAX
add eax, 158 ; add 158
mov sum, eax ; sum to memory
mov eax, 0 ; exit with return code 0
ret
main ENDP
END ; end of source code
上面给了我一个链接错误,而这个:
..
.CODE ; start of main program code
main:nop
mov eax, number ; first number to EAX
add eax, 158 ; add 158
mov sum, eax ; sum to memory
mov eax, 0 ; exit with return code 0
ret
end main ; end of source code
..
效果很好!
唯一的区别是main:nop vs main proc
这两者有什么区别,为什么一个是封闭的end main
,另一个是封闭的main endp main
?
这是我得到的错误:
1>------ Build started: Project: asm1, Configuration: Release Win32 ------
1> Assembling [Inputs]...
1>LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup
1>C:\Users\...\Downloads\asm1\Release\asm1.exe : fatal error LNK1120: 1 unresolved externals