flat assembler
Message board for the users of flat assembler.
Index
> Windows > MASM -> fasm (How to convert) |
Author |
|
LocoDelAssembly 28 May 2006, 22:16
Check this one
Code: include 'WIN32AXP.INC' HINSTANCE equ DWORD LPSTR equ DWORD HWND equ DWORD WPARAM equ DWORD LPARAM equ DWORD UINT equ DWORD .data ClassName db "SimpleWinClass",0 AppName db "Our First Window",0 hInstance dd ? CommandLine dd ? .code start: invoke GetModuleHandle, NULL mov [hInstance], eax invoke GetCommandLine mov [CommandLine], eax stdcall WinMain, hInstance,\ NULL,\ CommandLine,\ SW_SHOWDEFAULT invoke ExitProcess, eax proc WinMain, hInst:HINSTANCE,\ hPrevInst:HINSTANCE,\ CmdLine:LPSTR,\ CmdShow:DWORD local wc:WNDCLASSEX local msg:MSG local hwnd:DWORD mov [wc.cbSize], sizeof.WNDCLASSEX mov [wc.style], CS_HREDRAW or CS_VREDRAW mov [wc.lpfnWndProc], 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], 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, NULL,\ ClassName,\ AppName,\ WS_OVERLAPPEDWINDOW,\ CW_USEDEFAULT,\ CW_USEDEFAULT,\ CW_USEDEFAULT,\ CW_USEDEFAULT,\ NULL,\ NULL,\ [hInst],\ NULL mov [hwnd], eax invoke ShowWindow, [hwnd],\ SW_SHOWNORMAL invoke UpdateWindow, [hwnd] .while TRUE invoke GetMessage, addr msg,\ 0,\ 0,\ 0 test eax, eax jz .endWhile invoke TranslateMessage, addr msg invoke DispatchMessage, addr msg .endw .endWhile: mov eax, [msg.wParam] ret endp proc WndProc, hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM .if [uMsg]=WM_DESTROY invoke PostQuitMessage, NULL .else invoke DefWindowProc, [hWnd],\ [uMsg],\ [wParam],\ [lParam] ret .endif xor eax, eax ret endp .end start |
|||
28 May 2006, 22:16 |
|
Postal 29 May 2006, 08:45
Thank you!
|
|||
29 May 2006, 08:45 |
|
Postal 29 May 2006, 13:42
I'm added ".break" and ".breakif" directives.
Please check it. ;Before test eax, eax jz .endWhile ;Now: .breakif (~eax) Code: ;if.inc****************************** macro JCOND label,v1,c,v2 { match any,c \{ cmp v1,v2 j\#c label \} match ,c \{ PARSECOND parsed@cond,v1 match cond,parsed@cond \\{ JCONDEXPR label,cond \\} \} } macro .break { jmp __ENDW } macro .breakif [arg] { JCOND __ENDW,arg } Code: include '%fasminc%\win32ax.inc' include 'if.inc' HINSTANCE equ DWORD LPSTR equ DWORD HWND equ DWORD WPARAM equ DWORD LPARAM equ DWORD UINT equ DWORD .data ClassName db "SimpleWinClass",0 AppName db "Our First Window",0 hInstance dd ? CommandLine dd ? .code start: invoke GetModuleHandle, NULL mov [hInstance], eax invoke GetCommandLine mov [CommandLine], eax stdcall WinMain, [hInstance],\ NULL,\ [CommandLine],\ SW_SHOWDEFAULT invoke ExitProcess, eax proc WinMain, hInst:HINSTANCE,\ hPrevInst:HINSTANCE,\ CmdLine:LPSTR,\ CmdShow:DWORD local wc:WNDCLASSEX local msg:MSG local hwnd:DWORD mov [wc.cbSize], sizeof.WNDCLASSEX mov [wc.style], CS_HREDRAW or CS_VREDRAW mov [wc.lpfnWndProc], 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], 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, NULL,\ ClassName,\ AppName,\ WS_OVERLAPPEDWINDOW,\ CW_USEDEFAULT,\ CW_USEDEFAULT,\ CW_USEDEFAULT,\ CW_USEDEFAULT,\ NULL,\ NULL,\ [hInst],\ NULL mov [hwnd], eax invoke ShowWindow, [hwnd],\ SW_SHOWNORMAL invoke UpdateWindow, [hwnd] .while (TRUE) invoke GetMessage, addr msg,\ 0,\ 0,\ 0 ; test eax, eax ; jz .endWhile .breakif (~eax) invoke TranslateMessage, addr msg invoke DispatchMessage, addr msg .endw ; .endWhile: mov eax, [msg.wParam] ret endp proc WndProc, hWnd:HWND,\ uMsg:UINT,\ wParam:WPARAM,\ lParam:LPARAM .if ([uMsg]=WM_DESTROY) invoke PostQuitMessage, NULL .else invoke DefWindowProc, [hWnd],\ [uMsg],\ [wParam],\ [lParam] ret .endif xor eax, eax ret endp .end start |
|||
29 May 2006, 13:42 |
|
Postal 31 May 2006, 19:11
Code: ; Macroinstructions for HLL-style conditional operations macro .continue { jmp __WHILE } macro .continueif [arg] { JCOND __WHILE,arg } macro .break { jmp __ENDW } macro .breakif [arg] { JCOND __ENDW,arg } macro JCOND label,v1,c,v2 { match any,c \{ cmp v1,v2 j\#c label \} match ,c \{ PARSECOND parsed@cond,v1 match cond,parsed@cond \\{ JCONDEXPR label,cond \\} \} } COOL? |
|||
31 May 2006, 19:11 |
|
Postal 01 Jun 2006, 10:44
How to make in fasm section ".data?" ??
In MASM (for example): .data? buffer db 100000 dup (?) Then size of .exe file is SMALL !!!! In fasm: .data buffer db 100000 dup (?) Then size of .exe file is big... |
|||
01 Jun 2006, 10:44 |
|
LocoDelAssembly 01 Jun 2006, 13:58
|
|||
01 Jun 2006, 13:58 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.