flat assembler
Message board for the users of flat assembler.

Index > Main > flat assembler 1.61

Goto page Previous  1, 2, 3
Author
Thread Post new topic Reply to topic
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17639
Location: In your JS exploiting you and your system
revolution
Quote:

check for the comma in the pattern by preceding comma with =,
Post 08 Jun 2005, 08:52
View user's profile Send private message Visit poster's website Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy
This allows:
Code:
macro .if [val] {
  common
    local __endif
    match a == b,val \{
      cmp a,b
      jne __endif
    \}
    macro .endif \{
      __endif:
    \}
}    
Resulting in:
Code:
.if eax = 834
; code goes here
.endif    
Great work Privalov! Wink
Post 08 Jun 2005, 10:00
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7783
Location: Kraków, Poland
Tomasz Grysztar
revolution: no, the matches would loose its macro-like sense (where the parameters obtained from "match" would be applied?) - it is designed to be something different that just something like "if".
Post 08 Jun 2005, 12:28
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7783
Location: Kraków, Poland
Tomasz Grysztar
I've also got an idea that standard symbolic constants (defined with EQU) would be replaced in the matched symbols (the symbols after comma), so you could just use "DONE equ NO" etc. in the sample above (and reduce the need for FIX directive at all), and also "match =name,name" to check for not defined symbolic constant.
This would reduce need for the FIX directive only to the preprocessor symbol redefinition, since the other current applications could be substituted by use of "match" solely to replace the symbolic constants:
Code:
match replaced, arg { some_macro replaced }    

And then I could even try to redefine FIX directive (but break backward compatibility!!!) to get rid of the "double fixing" problems it causes.
Post 08 Jun 2005, 14:45
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
I don't get everything about new "match" directive. Why this code doesn't work?

Code:
macro .if [val] {
  common
    local __endif
    match  a ==== b,val \{
      cmp a,b
      jne __endif
    \}
    match a !== b,val \{
       cmp a,b
      je  __endif
    \}
    macro .endif \{
      __endif:
    \}
}



        mov     eax,1

        .if eax == 1
                nop
        .endif    


It is attmpt to make more complex .if macro, that allows == and != operators for comparing... but when I compile this, the second match directive also inserts the code.
Post 08 Jun 2005, 20:07
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7783
Location: Kraków, Poland
Tomasz Grysztar
The problem here is that for fasm ! is not special character so it is considered normal name. I can add it into table of special characters for that purpose, but this will disallow using ! inside the name. Hmmm, is anyone using names with "!" inside? And what about "?"?
Post 08 Jun 2005, 21:00
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc
I use "?" in some of my names
Post 08 Jun 2005, 22:35
View user's profile Send private message Visit poster's website Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix
Decard, try this code:

Code:
macro .if val {
  common
    PROCESSED equ NO
    local __endif
    match  a ==== b,val \{
      cmp a,b
      jne __endif
      PROCESSED equ YES
    \}
    match =NO a !== b,PROCESSED val \{
       cmp a,b
       je  __endif
    \}
    macro .endif \{
      __endif:
    \}
}    


It works in 1.61.11 release.
Regards.

_________________
Flat Assembler is the best!
Post 09 Jun 2005, 07:19
View user's profile Send private message Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen
Quote:
Hmmm, is anyone using names with "!" inside? And what about "?"?

I always wondered why fasm enables using such special characters in identifiers. Now, when we want to disable it (I think C-like if/endif would be very useful), we break backward compatibility Sad
Post 09 Jun 2005, 07:32
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
I can deal with breakage in backward compatibility - there has always been and there will always be somewhat bigger changes in the transform from 1.x => 1.(x+1) like between 1.4*-1.5* or 1.5*-1.6*

That is logical and I think we can cope with these changes to get a better FASM - that is more optimized for performance/size than optimized for compatibility.
Post 09 Jun 2005, 08:08
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen
Well, I'm porting my project to AMD64 architecture soon and I'm thinking of porting it from MASM to FASM. I can't imagine rewriting that large project every time new major version of FASM is released Sad
This is one of the advantages of MASM - it's syntax and rules are quite stable and there is almost 100% backward compatibility with previous versions.
Post 09 Jun 2005, 09:25
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7783
Location: Kraków, Poland
Tomasz Grysztar
Such things is advantage but might be a weak point at the same time - keeping the backward compatibility at any price can sometimes lead to terrible and almost unpredicatable syntax. And even MASM had some of its solutions gone obsolete after the better ones were implemented.

I tried to be very careful to avoid such things, when something not considered initially causes me to change mind about some design, but it seems I failed in case of FIX directive - but this syntax change actually won't actually visibly change the most of source, it only affects some of the macro constructions.

As for the ! character - I ask whether anyone's using it in names, because it's possible that such change wouldn't affect any of the things people have written. But as long as I'm not sure, I will keep the previous meaning of this character (anyway: decard, you can still check for ! if it's not special character by writing =!, it only has to be spaced correctly to not become attached to the preceding name).

I don't think any of this changes is anyway larger than the changes that were happening to MASM between some versions - do not worry, I wouldn't consider any changes that would affect really significantly the sources written for previous versions - they would affect all my code in the first place. Believe me: keeping backward compatibility was always my priority when designing any new features and if I break it, it means there are some really good reason for this.
Post 09 Jun 2005, 09:50
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen
Yea, I'm watching this board some time and therefore I know you are careful when you are implementing new features Smile

You're right, MASM contains some obsolete, useless and underdocumented features, but he is the patriarch, so we know what we can expect from him. By contrast, FASM is still a youngster and we don't know rather what we can expect from him Wink (I read Design Principles, very interesting, thanks for that)

Privalov, can you say how "mature" is FASM today? I mean, are there any sigificant features not yet implemented? For instance, the new MATCH directive significantly improves and simplifies the syntax, as I can see it from new macros.
Post 09 Jun 2005, 10:37
View user's profile Send private message Visit poster's website Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1137
Location: Russian Federation
comrade
Privalov wrote:
The problem here is that for fasm ! is not special character so it is considered normal name. I can add it into table of special characters for that purpose, but this will disallow using ! inside the name. Hmmm, is anyone using names with "!" inside? And what about "?"?


i use !

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 09 Jun 2005, 13:20
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7783
Location: Kraków, Poland
Tomasz Grysztar
OK, I will leave it unaffected.

(So if one needs C-like syntax, it just has to be "eax != 0" instead of "eax!=0".)
Post 09 Jun 2005, 13:28
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
Privalov wrote:
anyway: decard, you can still check for ! if it's not special character by writing =!, it only has to be spaced correctly to not become attached to the preceding name


Quote:
(So if one needs C-like syntax, it just has to be "eax != 0" instead of "eax!=0".)

Thanks for an explanation. Actually, I didn't want to use any HLL macros, I was just trying new directive Wink

BTW, Privalov, if you are about to add new features and change someting in FASM, I'm asking (again Wink) for some directive that will stop compilation.
Post 09 Jun 2005, 14:03
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7783
Location: Kraków, Poland
Tomasz Grysztar
My proposal: In the very similar way to the Intel that defined UD2 opcode to always generate interrupt 6 (as it always did anyway, since earlier it was just undefined instruction) I would guarantee that HALT will never be recognized by fasm as a valid instruction and therefore can used to stop compilation Wink
You can even follow it with your own message, since fasm displays the line that causes the error, you will see the message:
Code:
halt: wrong parameters    
Post 09 Jun 2005, 14:34
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
Wink I know about this solution of course.
Special directive for stopping compilation would be more elegant, but proably I won't convience you (at lest this time Very Happy).
Post 09 Jun 2005, 15:22
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:  
Goto page Previous  1, 2, 3

< 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 GitHub, YouTube, Twitter.

Website powered by rwasa.