flat assembler
Message board for the users of flat assembler.

Index > Main > flat assembler 1.61

Goto page Previous  1, 2, 3  Next
Author
Thread Post new topic Reply to topic
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7756
Location: Kraków, Poland
Tomasz Grysztar
Nickolay: well, this:
Code:
label alpha byte
times 3 db 'abcd',0
db ?
times 7 db '-'    

in terms of result is the same as:
Code:
alpha db 3 dup ('abcd',0), ?, 7 dup '-'    

but the latter is more convenient, isn't it?
And at least for people that are used to TASM/MASM this should be actual easement.
Post 03 Jun 2005, 18:38
View user's profile Send private message Visit poster's website Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
Hi Privalov
What do you think about Nickolay's idea of putting assembly file's name to the taskbar?

And BTW what does the 'dup' acronym mean?
www.acronymfinder.com gave me "Data User Part" but that is only somewhat logical Sad
Post 03 Jun 2005, 18:47
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov
Wow people you are a very fast Smile
Midas731 - sorry, may be my sense of humor is a strangely. Laughing
Privalov I agree. I use a primary fasm compiler for my prog and I have more problem with:
proc bla, var1:byte,var2:float,var3:dword,...
than "dup"
Post 03 Jun 2005, 18:58
View user's profile Send private message Reply with quote
Nikolay Petrov



Joined: 22 Apr 2004
Posts: 101
Location: Bulgaria
Nikolay Petrov
Madis731 I "want" when I have a too many fasm windows opened, I to know what is the asm script. "tab" window is a good but this is information not put in the taskbar.
For me it doesn't matter if in taskbar write:
flat assembler 1....[bla.asm]
or
bla.asm - flat assembler 1...


Last edited by Nikolay Petrov on 03 Jun 2005, 19:29; edited 2 times in total
Post 03 Jun 2005, 19:20
View user's profile Send private message Reply with quote
shaolin007



Joined: 03 Sep 2004
Posts: 65
shaolin007
Madis731 wrote:
Hi Privalov
What do you think about Nickolay's idea of putting assembly file's name to the taskbar?

And BTW what does the 'dup' acronym mean?
www.acronymfinder.com gave me "Data User Part" but that is only somewhat logical Sad


dup=duplicate
Post 03 Jun 2005, 19:26
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7756
Location: Kraków, Poland
Tomasz Grysztar
Quote:

I use a primary fasm compiler for my prog and I have more problem with:
proc bla, var1:byte,var2:float,var3:dword,...


You might try such "proc" macro variant:
Code:
macro proc name,[arg]
 { common
    if used name
    name:
    virtual at ebp+8
    if ~ arg eq
   forward
     label arg
     dd ?
   common
     end if
     ..ret = $ - (ebp+8)
    end virtual
    local ..data,..size
    if defined ..size
     virtual at ebp - ..size
    else
     if ..ret
      push ebp
      mov ebp,esp
     end if
    end if
    ..data:
    macro enter size,level
     \{ if size eq & level eq
         rb (4 - ($-..data) and 11b) and 11b
         if defined ..size
          ..size = $ - ..data
          end virtual
         else
          ..size = $ - ..data
         end if
         if ..ret | defined ..size
          push ebp
          mov ebp,esp
          if ..size
           sub esp,..size
          end if
         end if
        else
         enter size,level
        end if \}
    macro return
     \{ if ..ret | defined ..size
          leave
        end if
        if ..ret
         retn ..ret
        else
         retn
        end if \} }

macro endp
 { purge return
   purge enter
   end if }    

It allows syntax like:
Code:
proc foo, arg1:byte, arg2:dword
        mov     al,[arg1]
        mov     ebx,[arg2]
        return
endp    

But its weak point compared to standard fasm's "proc" macro is that the arguments are defined as global labels.


BTW, I have also once tried to reorganize fasm's macros to use "ret" keyword instead of "return" in procedures, just like it should be with procedures (also for kind of compatibility with TASM), but there was too strong opposition, because (probably because of NASM style) people expect RET keyword to generate the near return opcode - while it is RETN and RETF that are the actual mnemonics for near and far return, and RET should be able to generate any of the two depending on the context. I still think using this original meaning of RET would be better.
Post 03 Jun 2005, 20:49
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
Quote:
Version 1.61.9 brings a small suprise: I have implemented the DUP operator - one more thing to make conversion from TASM/MASM easier (and also in some cases DUP is much more handy than NASM-style TIMES):


Hmm, I use a macro named dup in my code. Will my macro still be useable without renaming it? (I'll try to test tomorrow, just to see).
Post 03 Jun 2005, 23:05
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7756
Location: Kraków, Poland
Tomasz Grysztar
Of course, there shouldn't be any problems. Macros and symbolic constants can override any keyword.
Post 03 Jun 2005, 23:12
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
Quote:
Of course, there shouldn't be any problems. Macros and symbolic constants can override any keyword.


Excellent! I just tested it, and sure enough it worked. Thanks for clarifying this for me.
Post 04 Jun 2005, 00:57
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7756
Location: Kraków, Poland
Tomasz Grysztar
The 1.61.10 release comes with one important fix and one new feature. The fix applies to ELF64 object output - I have misinterpreted the ELF64 specification according to the RELA relocations type and this caused previous versions to generate wrong code - now everything should be OK with ELF64 objects.

The new feature is the experimental "match" - the long awaited conditional preprocessing directive. However, as I wanted to base it on the macro handler in the similar way to "rept", I have designed it to allow even more interesting things.

The simplest description is: "match" checks whether the given chain of symbols matches the given pattern. Pattern comes first, the comma and potentially matching symbols next:
Code:
match +,+
{
 ; this will be preprocessed
}

match +,-
{
 ; there's no match, this won't be preprocessed
}    

The special characters and quoted strings in pattern have to be matched exactly, like in the sample above, however if you put any name symbol in pattern, it will match any chain of symbols. If you need some symbol to be matched exactly as is, precede it with = character.
Code:
match alpha, 1+1 { } ; match
match =alpha, 1+1 { } ; mismatch
match =alpha, alpha { } ; match    

So the = is interpreted specialy in pattern and symbol following is treated as pattern element to be compared exactly, so it also allows to check for the comma in the pattern by preceding comma with =, and to check for = character with the == sequence.

And what makes "match" something more than just simple conditional preprocessing is that the names which match any chain of symbols are then replaced inside the "match" block with those chains of symbols - just like macro parameters. For example:
Code:
match alpha+beta*gamma,1+2*3
 { db alpha,beta,gamma } ; becomes db 1,2,3    

Any name must match at least one symbol, it cannot match empty value:
Code:
match any,
 { } ; mismatch    

But each consecutive name is matched with as few symbols as possible:
Code:
match any other, 1+2*3
 {
   db any   ; db 1
   db other ; db +2*3
 }    

It should be obvious that this directive significantly extends the abilities of processing any macro parameters, se also the sample below.

I haven't managed to design any good solution for something like "else match", however "fix" directive can help again (at least until something better is invented):
Code:
macro freeform [arg]
 { common
     DONE fix NO
     match src->dst, arg
     \{
        mov dst,src
        \DONE fix YES
     \}
     match =NO dst<-src, DONE arg
     \{
        mov dst,src
        \DONE fix YES
     \}
     match =NO, DONE
     \{
        unrecognized syntax
     \}
 }

freeform eax -> ebx     ; mov ebx,eax

freeform al <- [esi+1]  ; mov al,[esi+1]    

Note that DONE constant is escaped inside "match" - this is required, because "match" (just like "rept") is processed similarly to macro, and therefore is actually processed twice - first it gets defined (and during the definition prioritized constants get replaced with their values) and only after the definition is completed preprocessor actually checks for the match and applies the macro when the match occurs. So if we wrote "DONE fix YES" inside the "match" block after the "DONE fix 0" definition, it would become "0 fix YES" before actuall processing of the macro (when the FIX directive would be interpreted) - thus the escaping was needed. This is a small flaw in my design, but I really think this is the best way how could I implement it.
Post 07 Jun 2005, 14:20
View user's profile Send private message Visit poster's website Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
pelaillo
Quote:

Code:
match any other, 1+2*3 
 { 
   db any   ; db 1 
   db other ; db +2*3 
 }    


How does the "any[blank]other" works here? Which are the symbols that work?
Post 07 Jun 2005, 17:47
View user's profile Send private message Yahoo Messenger Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7756
Location: Kraków, Poland
Tomasz Grysztar
Both "any" and "other" match any chain of symbols, but both will take as few symbols as possible - and so "any" matches only one symbol leaving rest for the "other", and "other" has to take all the rest of symbols since there is nothing more in pattern.
Post 07 Jun 2005, 17:51
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7756
Location: Kraków, Poland
Tomasz Grysztar
I've decided to disable replacing prioritized constant during the definition of in-place macro like "rept" or "match" - this will make it behave more like one would expect (at the cost of making impossible to "fix" any control operators for those structures).
Post 07 Jun 2005, 19:24
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17475
Location: In your JS exploiting you and your system
revolution
Can it be made similar to IF so that the ~ will mean not matched?

Code:
macro if_def name { match =defined,name \{ }

macro if_ndef name { match ~ =defined,name \{ }
    
Post 08 Jun 2005, 08:45
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
wow, preprocessor is becoming really messy... but at least we have lot of power with it.
I just like to know - is it possible to match "," character, since "<",">"s doesn't play any special role now...?
Post 08 Jun 2005, 08:46
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17475
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: 7756
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: 7756
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
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3  Next

< 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.