flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Is this a bug or what's wrong with this code ?

Author
Thread Post new topic Reply to topic
KRA



Joined: 14 Jun 2005
Posts: 24
KRA
Hi, I'm using fasm ver 1.62 (windows version).
With the following code I allways get compile error and the error message isn't that descriptive as I would like it to be since I can't understand it in whole.
Someone PLEASE help me get this right.

Code:
;       Module: fasmide.asm
;       Project:        Flat Assembler IDE
;       Version:        0.0.1
;       Author: Krister Alm                     kra             Krister.Alm@Home.se
;       
;       This is to be a fullblown IDe for working with fasm development. When done
;       there should be a working solution that runs on both Windows and Linux.
;
format PE GUI 4.0
entry start
include '%fasminc%/win32a.inc'

macro AddAPI param { match (name),param \{ macro name [params] \\{ \\common match (args),params \\\{ invoke name,args \\\} match =dd any,params \\\{ name dd any \\\} \\} \} } 

section '.idata' import data readable writeable

        library kernel, 'KERNEL32.DLL',\
                                user,           'USER32.DLL'
  
        import kernel,\
                GetModuleHandle,        'GetModuleHandleA',\
                GetCommandLine, 'GetCommandLineA',\
                ExitProcess,            'ExitProcess'

AddAPI(GetModuleHandle);
AddAPI(GetCommandLine);
AddAPI(ExitProcess);
                
        import user,\
                MessageBox,'MessageBoxA'

AddAPI(MessageBox);
                
section '.data' data readable writeable
        _szWelcome              db      "Welcome to the Flat Assembler IDE",0
        _szTitle                        db "Flat Assembler IDE",0
        
section '.udata' readable writeable
        hInstance               dd ?
        cmdln                           dd ?
        
section '.code' code readable executable

                
;       method: WinMain
;       purpose:        Performs program initializations and starts up the program.
;       returns: programs exitcode in 'eax'
proc    WinMain hInst, hPrevInst, CmdLine, CmdShow
        MessageBox( HWND_DESKTOP, _szWelcome, _szTitle, MB_OK );
        xor             eax,eax
        ret
endp

AddAPI(WinMain);


start:
        GetModuleHandle(NULL);
        push            eax
        GetCommandLine();
        pop             ebx
        WinMain( ebx, NULL, eax, SW_SHOWDEFAULT );
        
        ExitProcess( 0 );
        

    
Post 23 Jun 2005, 06:19
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
The AddAPI macro you've used is a wrapper to "invoke" macro, which is used to call API functions (imported from DLLs) indirectly (through double word pointers in memory) - the error you get means that the label you try to invoke has a bad type - it should be the label of double word pointer, while it's the procedure label. Make another version of this macro which will use the "stdcall" instead of "invoke", something like:
Code:
macro AddProc param { match (name),param \{ macro name [params] \\{ \\common match (args),params \\\{ stdcall name,args \\\} \\} \} }    
Post 23 Jun 2005, 07:20
View user's profile Send private message Visit poster's website Reply with quote
KRA



Joined: 14 Jun 2005
Posts: 24
KRA
Thanks, Now I can continue working.
Post 23 Jun 2005, 07:30
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.

Powered by rwasa.