flat assembler
Message board for the users of flat assembler.

Index > Windows > proc (newbie)

Author
Thread Post new topic Reply to topic
gnomen



Joined: 07 Oct 2003
Posts: 13
gnomen 14 Oct 2003, 15:06
I am trying to make a simple procedure for showing an error MessageBox, but it's wierd... look at this:
Code:
; in .data:
; _error db 'Error!',0
proc error, AText
    enter
        mov     eax, [AText]
        invoke  MsgBox,HWND_DESKTOP,eax,_error,MB_OK+MB_ICONERROR
        return      
    

And when I try to invoke it:
Code:
; in .data:
; _writefile db 'WriteFile error!',0
invoke  error,_writefile
    

I get the compiler message 'operand size not specified'?

OOPS Embarassed : Replacing invoke with stdcall made it work perfectly:
Code:
; in .data:
; _writefile db 'WriteFile error!',0
stdcall  error,_writefile
    
Post 14 Oct 2003, 15:06
View user's profile Send private message Reply with quote
MattBro



Joined: 08 Nov 2003
Posts: 37
MattBro 21 Nov 2003, 05:30
Looks familiar

I made the same mistake when I first started using this.
More than once in fact. When I look at the actual macro definition for invoke,

macro invoke proc,[arg] ; invoke procedure (indirect)
{ common
if ~ arg eq
stdcall [proc],arg
else
call [proc]
end if }


it seems that invoke uses the proc argument as a pointer to the procedure name, so it is an indirect call, whereas I suppose the proc call should be 'direct'.

_________________
-- -------------------------------------------------------
"I am the Way and the Truth and the Light, no one comes to the Father except through me" - Jesus
---------------------------------------------------------
Post 21 Nov 2003, 05:30
View user's profile Send private message Visit poster's website Reply with quote
eet_1024



Joined: 22 Jul 2003
Posts: 59
eet_1024 21 Nov 2003, 05:51
stdcall is used for calls to proc's in your code.

invoke is used to call functions that are imported from a DLL, such as kernel32.dll, user32.dll, or your own dll.

btw, you can push the contents of a stack frame:
invoke MsgBox,HWND_DESKTOP,[AText],_error,MB_OK+MB_ICONERROR
Post 21 Nov 2003, 05:51
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.