flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Macro instruction define

Author
Thread Post new topic Reply to topic
rydemstorm



Joined: 31 Oct 2012
Posts: 15
rydemstorm 07 Nov 2012, 18:49
Its possible in FASM doit something like that:
define IsAcc(reg) = reg in <al, ax, eax>
And later use:
macro ejemplo arg
{
if IsAcc(arg)
;something
else
;something
end if
}
Post 07 Nov 2012, 18:49
View user's profile Send private message Reply with quote
yoshimitsu



Joined: 07 Jul 2011
Posts: 96
yoshimitsu 07 Nov 2012, 22:37
You'd need to define IsAcc as a macro (as macros already are like C's defines with way more facilities), but FASM's macros can't return a value like MASM's can. They're also no simple textual substitution that can occur anywhere in the source like in C, they have to be invoked properly, so sth like "if IsAcc" is not possible.

What I did with TASM's macros back then was passing a local symbolic constant (equ) as a 'pointer' to the sub-macro. TASM handled those differently than FASM. With FASM, however, there is the preprocessing stage and the assembly stage. "if xx in <xx, xy>" is assembly stage, so equ (which is preprocessor stage) wouldn't work with it. But you can use constants ('=' instead of 'equ') which are assembly stage, like:

Code:
macro IsAcc reg,ret
 {
   if reg in <al,ax,eax>
    ret = 1
   else
    ret = 0
   end if
 }

macro test arg
 {
   local ret
   IsAcc arg,ret
   if ret
    display 'alright'
   else
    display 'nope'
   end if
 }    
Post 07 Nov 2012, 22:37
View user's profile Send private message Reply with quote
rydemstorm



Joined: 31 Oct 2012
Posts: 15
rydemstorm 07 Nov 2012, 23:17
I use something like that to solve the problem:
http://board.flatassembler.net/topic.php?t=14750
Post 07 Nov 2012, 23:17
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.