flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Is it safe to change bit operators with C/MASM syntax?

Author
Thread Post new topic Reply to topic
alorent



Joined: 05 Dec 2005
Posts: 221
alorent 10 Feb 2010, 11:19
Hello guys,

Is it safe (I mean, it won't introduce later issues) to create my own macros like:

Code:

!=   EQU  <>
!    EQU  ~
==   EQU  = 
&&   EQU  &
||   EQU  |
...
...

    


Well, I'm not sure if the above definitions are OK as it might cause double-replacing for "!=" when "!" is another macro.

Please, advice.

Thanks!!!
Post 10 Feb 2010, 11:19
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 10 Feb 2010, 12:51
alorent,

ASCII punctuation is almost used up in FASM. AFAIK only !?@^_ can be used in constant names safely (single and double quotes can be used too, only not as a first character). Thus most of your equs won't compile.

For example, "!= equ <>" is the definition of numeric constant named "!" with [invalid numeric expression] value of "equ<>".
Post 10 Feb 2010, 12:51
View user's profile Send private message Reply with quote
alorent



Joined: 05 Dec 2005
Posts: 221
alorent 10 Feb 2010, 13:36
Hi baldr,

Thanks for the explanation.

Isn't it possible to do it in another flavour? that is, without using EQUs.

Thanks!
Post 10 Feb 2010, 13:36
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 10 Feb 2010, 16:41
alorent,

I highly doubt it. From my analysis of PREPROCE.INC:

Tokenizer disallows the following ASCII codes in symbols:
Code:
db 9,0Ah,0Dh,1Ah,20h,'+-/*=<>()[]{}:,|&~#`;\'    
Along with NUL these codes delimit symbols.
Single and double quotes handled separately.
Thus we have:
!$%.?@^_ and alphanumeric, plus control characters not mentioned above and 80…FF — first-class name characters;
' and " — can be used if not first character.

As you can see, there is not a much left to choose from.
Post 10 Feb 2010, 16:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 10 Feb 2010, 17:12
Have you tried using 'fix'?
Post 10 Feb 2010, 17:12
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 10 Feb 2010, 17:47
revolution,

fix won't help.
Tokenized != fix <> is symbol("!")=symbol("fix")<>
(by symbol("name") I denote structure that holds symbol name).

symbol("fix") should be second token of line to be recognized by preprocessor (and in our case second token is =).
Post 10 Feb 2010, 17:47
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 10 Feb 2010, 18:04
baldr wrote:
For example, "!= equ <>" is the definition of numeric constant named "!" with [invalid numeric expression] value of "equ<>".
equs are symbolic constants not numeric constants (numeric constants are defined with '=', like 'a = 5'). It is perfectly possible for it to hold '<>', however the problem here comes from the name. The equal sign is a reserved symbol, so it won't work.

But for example this:
Code:
neq equ <>    
is perfectly ok

_________________
Previously known as The_Grey_Beast
Post 10 Feb 2010, 18:04
View user's profile Send private message Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 10 Feb 2010, 19:03
Borsuc,

I know what equ directive does, but FASM doesn't recognize "!= equ <>" as that directive. This line compiles as definition of numeric constant (and fails because "equ<>" does not compute).

OTOH, "! equ ~" defines symbolic constant "!" with value of "~" just fine.
Post 10 Feb 2010, 19:03
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 10 Feb 2010, 22:15
oh you're right, I didn't think about that. Clever Wink
Post 10 Feb 2010, 22:15
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.