flat assembler
Message board for the users of flat assembler.

Index > Main > weird behavior

Author
Thread Post new topic Reply to topic
khanh1984



Joined: 13 Jul 2009
Posts: 17
khanh1984
Hi everybody,

I've got some code below which I expected Fasm to catch error on compilation but it didn't.

Code:

; example of simplified Win32 programming using complex macro features
include "win32ax.inc"

.data
wc WNDCLASSEX                                      ; create local variables on stack
msg MSG 
hwnd dw 0


.code

start:
proc _Main
    mov   wc.cbSize,sizeofsdsd WNDCLASSEX                  ; fill values in members of wc
    mov   wc.style, CS_HREDRAW | CS_VREDRAW
    mov   wc.lpfnWndProc, asdddddddd
    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, wc                       ; register our window class 
    invoke CreateWindowEx,NULL,\ 
                ADDR ClassName,\ 
                ADDR AppName,\ 
                WS_OVERLAPPEDWINDOW,\ 
                CW_USEDEFAULT,\ 
                CW_USEDEFAULT,\ 
                CW_USEDEFAULT,\ 
                CW_USEDEFAULT,\ 
                NULL,\ 
                NULL,\ 
                hInst,\ 
                NULL 
    mov   hwnd,eax 
    invoke ShowWindow, hwnd,CmdShow               ; display our window on desktop 
    invoke UpdateWindow, hwnd    

        invoke CreateWindow
        invoke DialogBoxParam,NULL,IDD_DLG1001,NULL,DLG_Function,NULL
        invoke  MessageBox,HWND_DESKTOP,"Hi! I'm the example program!","Win32 Assembly",MB_OK
        invoke  ExitProcess,0
ret
endp

proc DLG_Function,hwnd,uMesg,wParam,lParam

ret
endp

.end start

;section '.rsrc'  data readable resource from 'rc.res'
    

please copy the above code and compile it to see by yourself.
Anyone have any explainations. (I've added many undeclared symbol to the code but strangely, fasm compiles sucessfully to whatever what you type into. I'm using ver 1.69 now
Post 13 Jul 2009, 08:14
View user's profile Send private message Reply with quote
MHajduk



Joined: 30 Mar 2006
Posts: 6034
Location: Poland
MHajduk
khanh1984 wrote:
I've got some code below which I expected Fasm to catch error on compilation but it didn't.

(...)

I've added many undeclared symbol to the code but strangely, fasm compiles sucessfully to whatever what you type into.
FASM doesn't complain about errors inside '_Main' procedure because you, in fact, don't call it in the program body (i.e. this procedure is never used and won't be included into executable). Try to insert
Code:
call _Main    
after the 'start' label and see what will happen. Wink
Post 13 Jul 2009, 10:16
View user's profile Send private message Visit poster's website Reply with quote
khanh1984



Joined: 13 Jul 2009
Posts: 17
khanh1984
thank you for your fast reply
Post 15 Jul 2009, 03:58
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
You could also change ".end start" with ".end _Main" and place the variables inside a locals block inside the proc to make the variables really local and stored on the stack.
Post 15 Jul 2009, 04:05
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.