articles » current » assembly » x86 » hello-windows

x86 Assembly: Hello Windows Example

Example Windows Program.

This simple example keeps looping until the user cancels it. Download the assembly source code:

TITLE Hello Windows

.model flat,stdcall
.stack 8192
ExitProcess PROTO, dwExitCode:DWORD
MessageBoxA PROTO, hwnd:DWORD, lpText:PTR BYTE, lpCaption:PTR BYTE, uiStyle:DWORD

hello BYTE "Hello Windows!",0

WinMain PROC

	mov   ebx, 40h          ; 64 is the information icon
	or    ebx, 1h           ; 1 is the OK/Cancel buttons
	pushd ebx               ; uiStyle
	mov   ebx, offset hello
	pushd ebx               ; lpCaption
	pushd ebx               ; lpText
	pushd 0                 ; hwnd
	call  MessageBoxA
	cmp   eax, 1h           ; 1 is the OK button being pressed; compare eax to 1
	je    msgbox            ; if eax equals 1, jump to msgbox:

	pushd 0
	call	ExitProcess

WinMain ENDP
END WinMain

This site uses cookies. Cookies are simple text files stored on the user's computer. They are used for adding features and security to this site. Read the privacy policy.