Yo all. I'm new in fasm so... please help me about some macro functions :>
1) How can macros return something like in masm -> EXITM ... ?
2) How can I create Struct with functions like in the c++ classes?
3) How can I make a macro like: MSGBOX('text', x, MB_OK) like in the hll?
4) How can I write in other sections with a macro:
(MASM:)
.data ; <~
wText db "bla bla bla",0
.code ; <~
-- --------------------------------------------------------
please help me I really need theese things
btw sorry about my bad english :)
Posted on 2003-04-11 05:12:20 by frk
hi,

Have you read the fasm doc, it has alot of examples and stuff. Might help you, its a great file. if you still have some questions then ask away.

to create a structure you do


struc somestruc
{
.something dd ?
.something2 dd ?
}
Posted on 2003-04-11 05:22:33 by keyoke
i how to make structures, but i need structures with functions in them - like in C++ classes
Posted on 2003-04-11 06:56:13 by frk
How to make a macro who returns a value and require brackets?
Something like MsgBox(param1,param2,param3)?
Could someone tell me please... i need this :(
Posted on 2003-04-11 15:40:27 by frk
What exactly do you mean by "returns a value"?
The assembly macro syntax doesn't use the brackets, it could be possible with some extended macro syntax I had been thinking of some time ago, but I haven't found to be really necessary (at least there wasn't large interest in it) at that's why I have never started implementing it.
Posted on 2003-04-11 16:00:34 by Tomasz Grysztar
Maybe something like the hll syntax:
;----
if msgbox('some','text',mb_yesno) == idyes
;----
I need something like in masm - 'exitm arg', but i didn't find nothing at the fasm manual... please tell me how to do this in fasm

p.s. sorry about my stupid posts but i'm new in fasm :)
Posted on 2003-04-11 16:43:02 by frk
It's not like the EXITM, be you need to test the value returned at run time, not at assembly time. Win32 API functions are returning the values in EAX register, so you'd just need to test the value of this register.
If you want to do it with some similar one-line syntax, you can do it using the following macro as a extension to the standard .if macros package (it's in FASMW distribution, in INCLUDE/MACRO/IF.INC file):


macro .iff func,c,num
{
__IF equ
local ..endif
__ENDIF equ ..endif
local ..else
__ELSE equ ..else
func
if num eq & c eq
cmp eax,0
je __ELSE
else
cmp eax,num
jn#c __ELSE
end if
}

It allows to use some function instead of register or memory operand for comparision.
Here's the example how you can use it:


macro MsgBox message,caption,flags
{
pushd flags
call @f
db caption,0
@@:
call @f
db message,0
@@:
pushd 0
call [MessageBox]
}

.iff <MsgBox "Some message","Some caption",MB_YESNO>,e,IDYES
MsgBox "You have answered YES!","Some caption",MB_OK
.endif
Posted on 2003-04-11 16:54:09 by Tomasz Grysztar
Tanx, this works really fine but how can I edit the .IF macro to do this? I want it just like in the hll languages
:)
Posted on 2003-04-11 17:21:21 by frk

Tanx, this works really fine but how can I edit the .IF macro to do this? I want it just like in the hll languages
:)


Why?
Posted on 2003-04-11 18:19:35 by bazik
Anyway you can merge these two syntaxes into one .if directive using the eqtype directive:


macro .if func,c,num
{
__IF equ
local ..endif
__ENDIF equ ..endif
local ..else
__ELSE equ ..else
if func eqtype eax | func eqtype [0]
if num eq & c eq
cmp func,0
je __ELSE
else
cmp func,num
jn#c __ELSE
end if
else
func
if num eq & c eq
cmp eax,0
je __ELSE
else
cmp eax,num
jn#c __ELSE
end if
end if
}
Posted on 2003-04-12 02:51:09 by Tomasz Grysztar
This is just the thing I needed :grin: thank you Privalov. :alright:
P.S Can you add the Switch (case) macro in the next version of Fasm it's good to have hll functions in a low level language :)
Posted on 2003-04-12 04:40:55 by frk
P.S Can you add the Switch (case) macro in the next version of Fasm it's good to have hll functions in a low level language


I would prefer to implement it as select/case (as in powerbasic) like this:

macro .select arg
{
__SELECT equ arg
__CASE equ _
local ..endselect
__ENDSELECT equ ..endselect
}

macro .case c,i
{
if ~ __CASE eq _
jmp __ENDSELECT
__CASE:
end if
local ..case
restore __CASE
__CASE equ ..case
cmp __SELECT,i
jn#c __CASE
}

macro .otherwise
{
if ~ __CASE eq _
jmp __ENDSELECT
__CASE:
restore __CASE
__CASE equ _
end if
}

macro .endselect
{
if ~ __CASE eq _
__CASE:
end if
__ENDSELECT:
restore __ENDSELECT
restore __CASE
restore __SELECT
}

and use them like this:

mov eax,
.select eax
.case e,WM_DESTROY
invoke PostQuitMessage,0
xor eax,eax
.otherwise
invoke DefWindowProc,,,,
.endselect

what do think guys? :)

Happy coding
Posted on 2003-04-15 11:57:49 by quiveror
If this macro works it will be perfect for my project :)
Posted on 2003-04-25 13:57:19 by frk
Those brackets you were talking about (and were planing to implement) would be very interesting... Is it to much to ask for (do you have too much to do?)?

Thanks for a great tool!
Posted on 2003-04-25 16:00:22 by Tommy