flat assembler
Message board for the users of flat assembler.

Index > Main > flat assembler 1.69.13

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Another bugfix-only release today.

If it is stable enough, I'm considering dropping the 1.68 from the download page, since some new features of 1.69 deserve to become "mainstream" after all. Perhaps I can some some releases of the 1.69.x line a "stable" one, and continue with another development releases from there?
I think 1.69.14 would be a good number. Wink So if there's anything more you'd like to have fixed for the new "small milestone", please let me know.
Post 09 Apr 2010, 18:10
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Tomasz Grysztar,

These are more like suggestions than fix requests, but nevertheless:

1. Can macro operators in macro arguments be properly backslashed during macro expansion? Here is the example:
Code:
macro iterate_cc [cc_var*, template*] {
;;; invokes template with all condition code mnemonics (valid for jcc) in cc_var
  irp cc_prefix,,n \{
    irp cc_suffix,,e \\{
      irps cc_mnemonic, a b g l \\\{
        match cc_var,cc_prefix\\\#cc_mnemonic\\\#cc_suffix \\\\{
          template; I propose \\\\template syntax, see below
        \\\\}
      \\\}
    \\}
    irps cc_mnemonic, c e o p s z \\{
      match cc_var,cc_prefix\\#cc_mnemonic \\\{
        template; \\\template here
      \\\}
    \\}
  \}
  irps cc_var, pe po cxz ecxz rcxz \{
    template; \template
  \}
}

iterate_cc cc, jnn#cc equ j#cc    
As you can see, template argument is replaced on different nesting levels, so static backslashing in invocation won't help. Wouldn't it break something to have FASM automatically add proper number of backslashes to symbol characters (especially macro operators) in actual argument? I propose that if backslashed symbol, \\\\template as an example of most nested, corresponds to formal parameter, it is replaced with actual parameter in which all symbols are +4-backslashed (if actual parameter contains backslashed symbol itself, its backslashing level is increased by 4).

2. When macro is invoked with more actual arguments than formal arguments declared, FASM throws the error "invalid macro arguments". Can this behavior be changed to vararg-like? I.e. last formal argument gets all the rest of actual arguments. I know about [] and common trick, I thought about possibility of "implicit match" between formal and actual arguments:
Code:
macro @ x,y { add x, y }
@ ebx,eax; this will act as the following:
match x=,y, ebx,eax { add x, y }; all symbol characters in formal arguments are escaped with =

macro ! x+=y { add x, y }; silly, I know
! eax += ebx; this is the same as
match x=+==y,eax += ebx { add x, y }

macro ! x-=y { sub x, y }
! ecx += edx; current definition won't match, using previous
! eax -= ebx; now current definition matches

macro for (element =in list) instruction {
  irp element, list \{ \instruction \}; backslash escape as proposed above
}
for (suffix in tsc, pmc) rd#suffix
match =(element =in list =) instruction, (suffix in tsc, pmc) rd\#suffix {; I need that backslash...
  irp element, list \{ instruction \}; to compile this with current FASM (see 1. above)
}

macro comment endcomment {
  macro ^ anything \{; This special «^» macro name matches start of line (hello, regexps! Wink)
    match =endcomment, anything \\{ purge ^ \\}
    ; so any line before «endcomment» occurrence is dropped as a whole
  \}
}    
Polymorphic macros? Why not?! Am I crazy enough? Wink
Post 11 Apr 2010, 05:54
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Ad 1. There's no such thing as "the proper number of backslashes". Preprocessor simply replaces the arguments with their values in the macro text, it doesn't know anything about whether this text itself will become another macro definition or not. And all the possible numbers of backslashes may be useful to macro write - that's why there's such mechanism in the first place (see examples in the Understanding fasm article.
I think that any modification in direction of "automated" escaping would actually make it worse.

Ad 2. Since you already know about [] and COMMON, which are there exactly for this purpose - why cannot you use them?
Post 11 Apr 2010, 10:58
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
Here's a quickly breeded example of how you can make the first one work. Though myself I'd perhaps prefer to define a custom syntax for templates that wouldn't use fasm's reserved operators at all.
Code:
macro iterate_cc [cc_var*, template*] {
;;; invokes template with all condition code mnemonics (valid for jcc) in cc_var 
  define _template template
  irp cc_prefix,,n \{
    irp cc_suffix,,e \\{ 
      irps cc_mnemonic, a b g l \\\{
        match cc_template,_template \\\\{
          match cc_var,cc_prefix\\\#cc_mnemonic\\\#cc_suffix \\\\\{
            cc_template
          \\\\\}
        \\\\} 
      \\\} 
    \\} 
    irps cc_mnemonic, c e o p s z \\{
      match cc_template,_template \\\{
        match cc_var,cc_prefix\\#cc_mnemonic \\\\{
          cc_template
        \\\\}
      \\\} 
    \\} 
  \}
  match cc_template,_template \{
    irps cc_var, pe po cxz ecxz rcxz \\{
      cc_template
    \\}
  \} 
} 

iterate_cc cc, jnn\\#cc equ j\\#cc    
Post 11 Apr 2010, 11:10
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Tomasz Grysztar,

Escaping is not "automated", it's kinda "propagated". I mean that occurrence of «\template» (given that actual template argument passed to macro is «jnn#cc equ j#cc») will be replaced with «\jnn\#\cc \equ \j\#\cc». This feature will give finer control of macro operators' context and argument replacement (if actual argument contains escaped symbols, they will be escaped more).

Vararg arguments are already partially implemented: you can pass less arguments than declared. [] and common looks like workaround (it works, but source became slightly less readable: you need to examine entire macro to decide whether this argument is indeed iterated in forward block or just "from here to the end" kind).

I'll try to implement these features to see if they're as useful as I think. Implicit match is entirely different issue, it requires good consideration (and alot of coding, I suppose). Special "caret" macro to process entire line? Hmmm… maybe.

Your example is analogous to my workaround #2 (thanks for efforts!), only I've used equ instead of define. First workaround was to implement template as separate macro (macro def_jnncc cc { jnn#cc equ j#cc }, then iterate_cc cc, def_jnncc cc).
Post 11 Apr 2010, 12:40
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
baldr wrote:
Escaping is not "automated", it's kinda "propagated". I mean that occurrence of «\template» (given that actual template argument passed to macro is «jnn#cc equ j#cc») will be replaced with «\jnn\#\cc \equ \j\#\cc».

The "\template" is currently not replaced by preprocessor at all - it just strips the backslash and the result is left in text, and MAY be later interpreted again by another macro constructor - that's how the escaping works. If you change this behavior, you're going to break some of the existing macros (including the one from "Understanding fasm" I pointed out to you).

baldr wrote:
Vararg arguments are already partially implemented: you can pass less arguments than declared.

This has nothing to do with varargs, you simply can omit a few arguments and they have an empty value then.
baldr wrote:
[] and common looks like workaround (it works, but source became slightly less readable: you need to examine entire macro to decide whether this argument is indeed iterated in forward block or just "from here to the end" kind).
It was designed specifically for this purpose and it's one of substantial features of fasm's macros since almost the beginning (it was introduced somewhere around 1.0x), it definitely is not a "workaround" - it is simply the way I have chosen.
Post 11 Apr 2010, 13:03
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Tomasz Grysztar,

Do you mean Defx and Parent / Child examples? Formal arguments are just placeholders, aren't those "name conflicts" artificial? I understand, they're written the way they are to demonstrate concept of backslash escape, but in real life I'd better name them differently if they have different purpose/context/whatever.

"Workaround" reference is related to only single case: when macro should accept arbitrary number of arguments and not going to iterate through them but use them as a whole. common and forward / reverse are unique features of FASM and I love them.

I'm not trying to convince you that those ideas are good or worth something. I'll give them a try and decide.
Post 11 Apr 2010, 13:30
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko
I'm not strong in macro so... how about FileAssociations dialog in fasmw.exe.
For you to be easy i did not improve it to the end i.e. there will be nothing
stored to the registry and you will get appropriate messages only('%type% reg-
istered', '%type% unregistered'). While writing it i was wondering a
directive over fix one:
Code:
  chunk patch1{
    mov     eax,2
    db      'lalala',\
            'oops ops etc'
    ;etc
  }

  chunk patch2{
    ;etc etc
  }

  ...
  patch1
  ...
  patch2
    



Well, all the patches to 'fasmw.asm' marked with ';;'.
Use \menu Options\Asserts...\ to see what they do.
Code:
1173:
        ;;
  cmp     eax,IDD_ASSERTS
     je      asserts
     ;;
3162:
        \;;
         IDD_ASSERTS,0,idd_asserts,\
       \;;
3312:
                ;;
          menuitem 'A&sserts...',IDD_ASSERTS
            ;;
3489:
  ;;
  IDD_ASSERTS = 0
  dialog idd_asserts,'',0,0,250,18,WS_CAPTION+WS_SYSMENU;,,,'Courier New',8
    dialogitem 'edit'      ,''   ,ID_EXPRESSION ,3,3,200,12  ,WS_VISIBLE+WS_TABSTOP+ES_AUTOHSCROLL+WS_BORDER
    dialogitem 'button' ,'ok' ,IDOK       ,216,3,30,12 ,WS_VISIBLE+WS_TABSTOP                          ,WS_EX_STATICEDGE
  enddialog

  asserts:
    invoke  DialogBoxParam,[hinstance],IDD_ASSERTS,dword[ebp+8],.wndproc,0
      jmp     finish
    .asserts   db 'asserts',0
    .def_asserts db 'to* bundle* a* type* end*it*with* & vice-versa',0
    .szASSERTS = 4096
    .wndproc:;wnd,msg,wParam,lParam
       push    ebx ebp esi edi
     lea     ebp,[esp+20]
        cmp     dword[ebp+4],WM_CLOSE
       je      .wm_close
   cmp     dword[ebp+4],WM_INITDIALOG
  je      .wm_initdialog
      cmp     dword[ebp+4],WM_COMMAND
     jne     .exit
       cmp     dword[ebp+8],IDOK
   jne     .exit
       ;START ok button pressed
    sub     esp,.szASSERTS
      invoke  SendDlgItemMessage,dword[ebp],ID_EXPRESSION,WM_GETTEXT,.szASSERTS,esp
       mov     esi,esp
     push    eax
 invoke  WritePrivateProfileString,_section_options,.asserts,esi,ini_path
    cld
 pop     ecx
 inc     ecx
 mov     edi,esi
    .load:
   lodsb
       cmp     al,' '
    jne     .not_space
    .space:
       lea     edx,[edi+1]
 neg     edx
 add     edx,esi
     cmovz   edi,esi
     jz      .start_updated
      ;<
       cmp     al,'*'
    mov     eax,_key_compiler_passes ;'passes'
        mov     edx,_priority_settings   ;'idle'
  cmovne  eax,edx
     push    ecx
 mov     byte[esi-1],0
       invoke  MessageBox,dword[ebp],edi,eax,0
     pop     ecx
 mov     edi,esi
     ;if al='*' then %ASSIGN% else %UNASSIGN%
  ;restore ecx
        ;edi = esi
  ;<
       jmp     .start_updated
    .not_space:
       test    al,al
       jz      .space
      cmp     al,9
        je      .space
      cmp     al,10
       je      .space
      cmp     al,13
       je      .space
      cmp     al,'*'
    je      .space
    .start_updated:
   loop    .load
    .done:
     add     esp,.szASSERTS
      jmp     .wm_close
    ;END ok button pressed
    .wm_initdialog:
  invoke  SendMessage,dword[ebp],WM_SETTEXT,0,.asserts
        sub     esp,.szASSERTS
      mov     eax,esp
     invoke  GetPrivateProfileString,_section_options,.asserts,.def_asserts,eax,.szASSERTS,ini_path
      invoke  SendDlgItemMessage,dword[ebp],ID_EXPRESSION,WM_SETTEXT,0,esp
        add     esp,.szASSERTS
      jmp     .exit
    .wm_close:
 invoke  EndDialog,dword[ebp],'cool'
    .exit:
     xor     eax,eax
     pop     edi esi ebp ebx
     ret     16
  ;;
    


Description: fasmw.asm, native_fasmw.asm, fasmw.exe, changes.log
Download
Filename: ~.rar
Filesize: 89.43 KB
Downloaded: 286 Time(s)

Post 12 Apr 2010, 05:32
View user's profile Send private message Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko
Like a baby i am:)
-eager active line highlight; fasm is a default *.txt,*.ini,*.inf etc reader in our system and taking a rest makes tired searching for a line; of course we can make selection before Sad
-some ini-option could be included "Allow nested comments", plea-ea-ea-ea-ea-ea-ea-ea-ea-sss-eeeeeee :\

ok, here is my nipple(we are studying on Saturdays)
Post 24 Apr 2010, 06:02
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
version 1.69.14 (Apr 26, 2001) <-- Razz

[-] Fixed corruption of stored state of nested structures in case when they were
closed out of order.
Post 27 Apr 2010, 17:27
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
it doesn't compile correctlly shell.asm http://board.flatassembler.net/download.php?id=4910
Sad

but 1.68 does. Smile

when comparing both files, it appears a lot of differences. maybe due to alignment...
Post 27 Apr 2010, 17:50
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
edfed,

Both don't, because included "crypt001.txt" is missing. Wink
With it (empty) they compile to almost identical binaries, except (I skip incidental differences, like rel8 in jcc changed due to those listed):
  1. FOOL\GNODE.INC [38]: call eax missing opsize prefix (1.68);
  2. FOOL\MOUSE.INC [70]: call edx missing opsize prefix (1.68);
  3. FOOL\KEYBOARD.INC [48]: call eax missing opsize prefix (1.68);
  4. FOOL\KEYBOARD.INC [90]: call eax missing opsize prefix (1.68);
  5. FOOL\INIT.INC [9]: call eax missing opsize prefix (1.68);
  6. FOOL\PARSE.INC [66]: call eax missing opsize prefix (1.68);
  7. FOOL\Xhtml.inc [73]: call eax missing opsize prefix (1.68);
  8. FOOL\INT33.INC [56]: call edx missing opsize prefix (1.68);
  9. FOOL\pixel.inc [32]: call edx missing opsize prefix (1.68);
As you can see, all the differences were due to fixed in 1.69.11 bug (and your code looks small enough for these erroneous instructions to work as expected).

Hell, man, aren't you curious enough to look into those differences yourself? It's your code!
Post 28 Apr 2010, 05:16
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
ok, i see the thing.
but it means something i don't understand.

what should be the prefix?

corrected with call near eXx, still don't work.


Last edited by edfed on 28 Apr 2010, 07:46; edited 1 time in total
Post 28 Apr 2010, 07:39
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: 17278
Location: In your JS exploiting you and your system
revolution
edfed: It is not the 'near' that you need, it is the opsize prefix '0x66'.

Without the opsize prefix the instruction is 'call ax'. So previously fasm was generating the wrong instruction.

Change all your 'call eXx' to 'call Xx' and you will get back your original binary.
Post 28 Apr 2010, 07:44
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr
Have anyone detected silent update to 1.69.14? Wink
Post 28 Apr 2010, 07:46
View user's profile Send private message Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
ok, that was that point that leaved me in error state. Very Happy

i correct this right now then.
Post 28 Apr 2010, 07:47
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: 17278
Location: In your JS exploiting you and your system
revolution
Post 28 Apr 2010, 07:49
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4237
Location: 2018
edfed
ok, got it right now.
i was very far to think about a missing prefix as i debug with Hxd to see the labels where error occurs, but there was no error, nothing worked at all.

then, let's upadate to 1.69.14 and use rss Wink
Post 28 Apr 2010, 07:55
View user's profile Send private message Visit poster's website Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko
Tomasz, (hi) make display dialog with a mono-width font please: eyes tired.
= Thanks
Post 10 May 2010, 17:58
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
edemko wrote:
Tomasz, (hi) make display dialog with a mono-width font please: eyes tired.
= Thanks
Please try it now.
Post 10 May 2010, 18:45
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 1, 2  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.

Powered by rwasa.