flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > preprocessor define directive

Author
Thread Post new topic Reply to topic
shutdownall



Joined: 02 Apr 2010
Posts: 518
Location: Munich
shutdownall
I have a question regarding define directive in preprocessor.

How can I replace/define a string with another string ?
It's about mod operator, some assemblers use % for mod operator.
But % could be used in another context (for defining binary values).

Code:
format binary as "p"

define % mod

        org 0h
        mov al,(labelx+1) % 100h

        org 1adfh
labelx:
    


This example works but is problematic when % used in another context.
I tried to replace the string " % " with one leading and one trailing space but FASM throws error "invalid name".

Code:
define " % " mod
    


Does anybody know how to realize this ?
Post 21 Jan 2012, 14:36
View user's profile Send private message Send e-mail Reply with quote
cod3b453



Joined: 25 Aug 2004
Posts: 619
cod3b453
You could use "% fix mod" but % has special meanings in FASM when used with other directives such as repeat.
Post 21 Jan 2012, 18:56
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
No, it is not possible to have strict textual replacements done by fasm's preprocessor, because it does not operate on original source text, but on the pre-tokenized data. You may find details of this process explained in Understanding fasm article.
Post 23 Jan 2012, 11:48
View user's profile Send private message Visit poster's website 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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.