flat assembler
Message board for the users of flat assembler.

Index > Main > push macro

Author
Thread Post new topic Reply to topic
killasmurf86



Joined: 29 Sep 2010
Posts: 36
killasmurf86 31 Oct 2010, 16:10
Is it somehow possible to
Code:
push macro_name macro_parameter    


I want to know if it's possible for macro to "return" value, that will be pushed?
Post 31 Oct 2010, 16:10
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 31 Oct 2010, 16:19
killasmurf86,

Macro is a macro, it has nothing to do with instructions (it's assembler stage's work). Could you show an example of what you're trying to achieve?
Post 31 Oct 2010, 16:19
View user's profile Send private message Reply with quote
killasmurf86



Joined: 29 Sep 2010
Posts: 36
killasmurf86 31 Oct 2010, 18:17
I need analogue to http://fxr.watson.org/fxr/source/sys/ioccom.h?v=FREEBSD8
So later I can use puch _IOW(g,n,t) for example

Currently I work around this by inserting push in one of macros.... this works quite well, but code doesn't look so readable

here's part of code, that reads vol from /dev/mixer on FreeBSD

Code:
SIZEOF_INT                     = 4 ; for 64bit arch should be 8

IOCPARM_SHIFT                           = 13
IOCPARM_MASK                            = (1 shl IOCPARM_SHIFT) - 1
macro IOCPARM_LEN x              { (x shr 16) and IOCPARM_MASK }
macro IOCBASECMD x                 { x and not (IOCPARM_MASK shl 16) }
macro IOCGROUP x               { (x shr 8) and 0xFF }
IOC_VOID                            = 0x20000000
IOC_OUT                                 = 0x40000000
IOC_IN                                  = 0x80000000
IOC_INOUT                       = IOC_OUT or IOC_IN
IOC_DIRMASK                      = IOC_VOID or IOC_OUT or IOC_IN
macro _IOC inout, group, num, len   { push inout or ((len and IOCPARM_MASK) shl 16) or (group shl 8) or num }
macro _IO g, n                            { _IOC IOC_VOID, g, n, 0 }
macro _IOWINT g, n              { _IOC IOC_VOID, g, n, SIZEOF_INT }
macro _IOR g, n, t             { _IOC IOC_OUT, g, n, t } ; t must be sizeof
macro _IOW g, n, t                    { _IOC IOC_IN, g, n, t }  ; t must be sizeof
macro _IORW g, n, t                   { _IOC IOC_INOUT, g, n, t }       ; t must be sizeof

macro MIXER_READ dev              { _IOR 'M', dev, SIZEOF_INT } 
macro MIXER_WRITE dev             { _IOW 'M', dev, SIZEOF_INT } 

...
    push    vol
    MIXER_READ SOUND_MIXER_VOLUME
    push    eax
    push    eax
    mov          eax,SYS_IOCTL
    int        0x80
    lea         esp,[esp+4*4]
    jc         error
    mov        eax,[vol]
    

SOUND_MIXER_VOLUME is constant (also calculated in source)
Post 31 Oct 2010, 18:17
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 31 Oct 2010, 18:55
killasmurf86,

You're taking wrong measures against inexistent problems. That .H file doesn't define (almost) anything besides constants.
Post 31 Oct 2010, 18:55
View user's profile Send private message Reply with quote
killasmurf86



Joined: 29 Sep 2010
Posts: 36
killasmurf86 31 Oct 2010, 20:12
I now....
But it's the way how it defines constants
Post 31 Oct 2010, 20:12
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.