flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > C to FASM define/macro conversion

Author
Thread Post new topic Reply to topic
arafel



Joined: 29 Aug 2006
Posts: 131
Location: Jerusalem, Israel
arafel 29 Aug 2006, 10:33
Hello everyone,

I am having trouble with converting something from C to FASM:
Code:
#define _IOC(dir,type,nr,size) \
(((dir) << _IOC_DIRSHIFT) | \
((type) << _IOC_TYPESHIFT) | \
((nr) << _IOC_NRSHIFT) | \
((size) << _IOC_SIZESHIFT))

#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(size))

#define TEST _IOR('t', 90, 4)    

Basically I want to make the FASM variant as close to C as possible:
Code:
macro _IOC dir,type,nr,size
{((dir shl _IOC_DIRSHIFT) or (type shl _IOC_TYPESHIFT) or (nr shl _IOC_NRSHIFT) or (size shl _IOC_SIZESHIFT))}

macro _IOR type, nr, size {_IOC _IOC_READ, type, nr, size}

TEST equ (_IOR 't', 90, 4) ; <--- the problem.    

Is there any way to make FASM to assign a result of a macro instead of the macro invoking string? Or any other way to do this?

Sorry if I posted in a wrong section. Wasn't sure if it should come here or in the main.
Post 29 Aug 2006, 10:33
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 29 Aug 2006, 11:53
macros can be used only on place where you can also put instruction. what you want is called "inline macro", and this isn't supported, search the board for "inline macro" to see why
Post 29 Aug 2006, 11:53
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
arafel



Joined: 29 Aug 2006
Posts: 131
Location: Jerusalem, Israel
arafel 29 Aug 2006, 14:02
Uhh. So it's impossible to do this...

Thanks for the reply.
Post 29 Aug 2006, 14:02
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.