Assembly language examples using NASM on Windows
Message Box - 32 bit
Description
Display a message in a standard Windows Message Box, 32 bit.
Assemble
- nasm -f win32 MessageBox32.asm -o MessageBox32.obj
Link
- golink /entry:Start kernel32.dll user32.dll MessageBox32.obj
- polink /ENTRY:Start /SUBSYSTEM:WINDOWS /LIBPATH:c:\lib32 kernel32.lib user32.lib MessageBox32.obj
Notes
Double click the icon to run the executable.
The Message Box exits when the Yes (to exit) button is clicked.
Code
NULL EQU 0
MB_DEFBUTTON1 EQU 0
MB_DEFBUTTON2 EQU 100h
IDNO EQU 7
MB_YESNO EQU 4
extern _MessageBoxA@16
extern _ExitProcess@4
global Start
section .data
MessageBoxText db "Do you want to exit?", 0
MessageBoxCaption db "MessageBox 32", 0
section .text
Start:
push MB_YESNO | MB_DEFBUTTON2
push MessageBoxCaption
push MessageBoxText
push NULL
call _MessageBoxA@16
cmp EAX, IDNO
je Start
push NULL
call _ExitProcess@4