the last line in the file...
end starttells the assembler where the program entry point is
this is where execution begins when you run the program
you don't want that to point to your MyFunc PROC
also, it is sometimes nice to be able to move things around
i.e., you might like the INVOKE to appear before the PROC
in order for that to work, the assembler needs a PROTO type
and, this is 32-bit world
we want the parameter to be a dword to keep the stack aligned
when you run the program, open a console window, then type in the name
not using ExitProcess is not a good idea - lol
there are ways to make it wait for a keypress before exiting
but, let's get you started, first :P
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
MyFunc PROTO :DWORD
.data
output db "Hello World!", 0ah, 0h
.data?
hStdOut HANDLE ?
.code
start:
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov hStdOut,eax
invoke MyFunc,13d
invoke ExitProcess, 0 ;comment out to keep process from returning to windows immediately
MyFunc proc param1:DWORD
LOCAL bytesWritten :DWORD
invoke WriteConsole, hStdOut, addr output, param1, addr bytesWritten, NULL
mov eax,bytesWritten ;return the byte count in EAX
ret
MyFunc EndP
end start