The MASM Forum

Projects => Poasm => Topic started by: Vortex on October 11, 2012, 05:39:17 AM

Title: Poasm project built with Pelles C IDE
Post by: Vortex on October 11, 2012, 05:39:17 AM
Here is a GUI example built with Pelles C IDE. The code displays a simple window.

.386
.model flat,stdcall
option casemap:none

include     Window.inc

WinMain     PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc     PROTO :DWORD,:DWORD,:DWORD,:DWORD

.data
ClassName   db "WndClasss",0
AppName     db "Window",0

.data?
hInstance   dd ?

.code

start:

    invoke  GetModuleHandle,0
    mov     hInstance,eax
    invoke  GetCommandLine
    invoke  WinMain,hInstance,NULL,eax,SW_SHOWDEFAULT
    invoke  ExitProcess,eax

WinMain PROC hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,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, 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,NULL,ADDR ClassName,ADDR AppName,\
            WS_OVERLAPPEDWINDOW or WS_VISIBLE,100,\
            100,500,400,NULL,NULL,\
            hInst,NULL
    mov     hwnd,eax
    invoke  UpdateWindow,hwnd
   
    .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:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD

           
    .IF uMsg==WM_DESTROY
        invoke  PostQuitMessage,NULL

    .ELSE
        invoke  DefWindowProc,hWnd,uMsg,wParam,lParam       
        ret
       
    .ENDIF
   
    xor     eax,eax
    ret

WndProc ENDP

END start
Title: Re: Poasm project built with Pelles C IDE
Post by: farrier on October 11, 2012, 08:07:41 AM
Vortex,

Thanks for the example!  How would a 64-bit simple window program differ?

farrier
Title: Re: Poasm project built with Pelles C IDE
Post by: Vortex on October 12, 2012, 04:54:23 AM
Hi farrier,

Japheth provides some simple 64-bit simple window examples. You can download JWasm to get them :

http://japheth.de/JWasm.html

You can decompress the content of JWasm208abw.zip and check the example Win64_2.asm. It could be converted to Poasm.
Title: Re: Poasm project built with Pelles C IDE
Post by: farrier on October 12, 2012, 12:40:43 PM
Thanks Vortex,

I'll try my hand at doing it in PoAsm.  If it works, I'll post here.

farrier