Hi, Folks, I am starting with masm32, I am trying to compile, link and build this assembler program:
.586
.model flat, stdcall
option casemap :none ; case sensitive
include d:\masm32\include\windows.inc
include d:\masm32\include\user32.inc
include d:\masm32\include\kernel32.inc
include d:\masm32\include\gdi32.inc
includelib d:\masm32\lib\user32.lib
includelib d:\masm32\lib\kernel32.lib
includelib d:\masm32\lib\gdi32.lib
.data
hProcess dd 0
hThread dd 0
oldPrio dd 0
oldPrioClass dd 0
theLoWord dd 0
theHighWord dd 0
.code
invoke GetCurrentProcess
mov hProcess,eax
invoke GetPriorityClass,hProcess
mov oldPrioClass,eax
invoke GetCurrentThread
mov hThread,eax
invoke GetThreadPriority,hThread
mov oldPrio,eax
invoke SetPriorityClass,hProcess,REALTIME_PRIORITY_CLASS ; equ 100h
invoke SetThreadPriority,hThread,THREAD_PRIORITY_TIME_CRITICAL ; equ 0Fh
invoke Sleep,10
rdtsc
mov theLoWord,eax
mov theHighWord,edx
invoke Sleep,500
rdtsc
sub eax, theLoWord
sbb edx, theHighWord
mov theLoWord, eax
mov theHighWord, edx
invoke SetThreadPriority,hThread,oldPrio
invoke SetPriorityClass,hProcess,oldPrioClass
mov eax,theLoWord
xor edx,edx
mov ebx,500000
div ebx
end
When I compile the program there is no error, but when I link it the next error appears: "LINK : error LNK2001: unresolved external symbol _WinMainCRTStartup Prueba.exe : fatal error LNK1120: 1 unresolved externals".
In other posts some people obtain the same error and the solution appears to be downloading a Link16 executable, I have already tried this fix but it has not been succesful, moreover, my OS is Windows 2000 Professional SP 4 which I think is 32 bits OS. Could you please help me?. I am using MASM32 9. Thanks in advance.
Try this
.code
start proc
invoke GetCurrentProcess
{etc...}
div ebx
{I assume you will do something with the DIV result here}
invoke ExitProcess,0
start endp
end start
The 'end' directive needs a label to tell the linker where the entry point of the program is.
(You won't need the 16-bit linker, this is pure win32 code.)
Thank you sinsi, the problem has been solved.
can also be
.code
start:
;;/// Your code
invoke exitprocess,NULL
;-------------------------------
another proc
another endp
end start