I guess you are trying to do something like this.
MessageBox is called by ordinal in this example.
[Ordinal will change depending on the dll version. We might need to use tools like PE/DLL Viewer to get the correct one.]
;;Assemble with:
;;nasm -fobj HelloOrd.asm
;;Link with:
;;alink -c -oPE -subsys gui HelloOrd.obj
%include "win32n.inc"
extern GetProcAddress
import GetProcAddress kernel32.dll
extern LoadLibraryA
import LoadLibraryA kernel32.dll
global ..start
segment .data USE32
message db "Hello World!",0
msgtitle db "Hello",0
dllname1 db "user32.dll",0
apiname1 db "MessageBoxA",0
hMod dd 0
OrdinalMsgBox dd 0
segment .bss USE32
segment .code USE32 class=code
..start:
push dword dllname1
call [LoadLibraryA]
mov [hMod],eax ;; Save Module Handle for User32.dll
push dword 2039 ;; Alternatively use function name ;;; push dword apiname1
push dword [hMod]
call [GetProcAddress] ;; Get the Address of MessageBox api function.
mov [OrdinalMsgBox],eax
cmp eax,0
jz ExitOut ;; if zero then something is wrong
push dword MB_OK
push dword msgtitle
push dword message
push dword 0
call [OrdinalMsgBox] ;; call the function.
ExitOut:
ret