Hello, I have begun to learn assembly and I'm trying to understand the following code:
.386
.model flat, stdcall
option casemap :none
include E:\masm32\INCLUDE\windows.inc
include E:\masm32\INCLUDE\kernel32.inc
include E:\masm32\INCLUDE\user32.inc
includelib E:\masm32\LIB\kernel32.lib
includelib E:\masm32\LIB\user32.lib
WinMain proto :DWORD, :DWORD, :DWORD, :DWORD
.data
ClassName db "WinClass", 0
AppName db "Simple Window", 0
.data?
hInstance HINSTANCE ?
.code
start:
invoke GetModuleHandle, NULL
mov hInstance, eax
invoke WinMain, hInstance, NULL, NULL, 0
invoke ExitProcess, eax
WinMain proc hInst:HINSTANCE, hPrevInst:HINSTANCE, CmdLine:LPSTR,
CmdShow:DWORD
local wc:WNDCLASSEX
local msg:MSG
local hwnd:HWND
mov wc.cbSize, SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, offset WndProc
mov wc.cbClsExtra, NULL
mov wc.cbWndExtra, NULL
push hInstance
pop wc.hInstance
mov wc.hbrBackground, COLOR_WINDOW+1
mov wc.lpszMenuName, NULL
mov wc.lpszClassName, offset ClassName
invoke LoadIcon, NULL, IDI_APPLICATION
mov wc.hIcon, eax
mov wc.hIconSm, eax
invoke LoadCursor, NULL, IDC_ARROW
mov wc.hCursor, eax
invoke RegisterClassEx, addr wc
invoke CreateWindowEx, 0, addr ClassName, addr AppName, WS_OVERLAPPEDWINDOW\
or WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,\
CW_USEDEFAULT, NULL, NULL, hInst, NULL
mov hwnd, eax
.while TRUE
invoke GetMessage, addr msg, NULL, 0, 0
.break .if (!eax)
invoke TranslateMessage, addr msg
invoke DispatchMessage, addr msg
.endw
mov eax, msg.wParam
ret
WinMain endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
.if uMsg == WM_DESTROY
invoke PostQuitMessage, 0
.else
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
.endif
xor eax, eax
ret
WndProc endp
end start
As I understand it, the ret mnemonic returns to the next instruction that comes after the called function.
Why isn't there a ret mnemonic after the CreateWindowsEx function and the GetMessage, TranslateMessage, and DispatchMessage functions?
On the other hand, it's there after the while loop and DefWindowProc and WndProc.
I'm sorry if this question is dumb, but I really want to understand when to use the ret mnemonic, and when to not use it.