4
I was seeing a creation of a basic window on Assembly that displays a message, already installed the compiler NASM but error to compile.
.386
.MODEL FLAT, STDCALL
INCLUDE windows.inc
INCLUDE kernel32.inc
INCLUDE user32.inc
INCLUDELIB kernel32.lib
INCLUDELIB user32.lib
.DATA
WndClsName BYTE "AsmWnd", 0h;
WndTitleName BYTE "Hello, World!", 0h;
MsgBoxTxt BYTE "Programadores de verdade programam assim", 0h;
CmdShow DWORD SW_SHOWDEFAULT;
.DATA?
window WNDCLASSEX {};
hInstance HINSTANCE ?;
hWnd HWND ?;
message MSG {};
.CODE
Entry:
push 0h;
call GetModuleHandle;
mov hInstance, eax;
mov window.cbSize, SIZEOF WNDCLASSEX;
mov window.hbrBackground, COLOR_WINDOW;
mov window.hIcon, 0h;
mov window.hIconSm, 0h;
mov window.cbClsExtra, 0h;
push IDC_HAND;
push 0h;
call LoadCursor;
mov window.hCursor, eax;
push hInstance;
pop window.hInstance;
mov window.lpszMenuName, 0h;
mov window.lpszClassName, OFFSET WndClsName;
mov window.style, CS_VREDRAW or CS_HREDRAW;
mov window.lpfnWndProc, OFFSET WndProc;
push eax;
lea eax, window;
push eax;
call RegisterClassEx;
pop eax;
push 0h;
push hInstance;
push 0h;
push 0h;
push 250d;
push 250d;
push 250d;
push 250d;
push WS_OVERLAPPEDWINDOW;
lea eax, WndTitleName;
push eax;
lea eax, WndClsName;
push eax;
push WS_EX_TOPMOST;
call CreateWindowExA;
mov hWnd, eax;
cmp hWnd, 0h;
jne _Ok;
push 1h;
call ExitProcess;
_Ok:
push CmdShow;
push hWnd;
call ShowWindow;
push hWnd;
call UpdateWindow;
_GetMessageLoop:
push 0h;
push 0h;
push 0h;
lea eax, message;
push eax;
call GetMessage;
cmp eax, 0h;
je _EndMessageLoop;
lea eax, message;
push eax;
call TranslateMessage;
lea eax, message;
push eax;
call DispatchMessage;
jmp _GetMessageLoop;
_EndMessageLoop:
mov eax, message.wParam
WndProc proc hWindow:HWND, uMsg:UINT, wParam:DWORD, lParam:DWORD
cmp uMsg, WM_DESTROY;
je _WM_DESTROY;
cmp uMsg, WM_LBUTTONDOWN;
je _WM_LBUTTONDOWN;
push lParam;
push wParam;
push uMsg;
push hWindow;
call DefWindowProc;
jmp _EndWndProc;
_WM_LBUTTONDOWN:
push MB_OK or MB_ICONINFORMATION;
push OFFSET WndTitleName;
push OFFSET MsgBoxTxt;
push hWindow;
call MessageBoxA;
jmp _EndWndProc;
_WM_DESTROY:
push 0h;
call PostQuitMessage;
_EndWndProc:
Ret
WndProc EndP
END Entry;
It seems to be the syntax of MASM. Post the error messages.
– stderr
And how to compile?
– user24410
If it is MASM, with the MASM compiler.
– stderr
So it is in Masm.
– user24410