flat assembler
Message board for the users of flat assembler.

flat assembler > Macroinstructions > [solved] fasm1: needed mismatch directive

Author
Thread Post new topic Reply to topic
ProMiNick



Joined: 24 Mar 2012
Posts: 353
Location: Russian Federation, Sochi
needed absolutely sintactical identic to match its contrpart directive mismatch no matter via macros or internal

if we introduce new syntax element it should accept all intuitive syntax cases (but for now it accepts only one of 4 possible)
Code:
macro mismatch line&
{
        local flag1, flag2
        match statement =\{ action =\}, line
        \{       flag1 equ
                match statement \\{ flag2 equ \\}
                match any,flag2 \\{ action \\} \}
        match statement =\{ action, line
        \{       flag1 equ
                match statement \\{ flag2 equ \\}
                match any,flag2 \\{ action \}
        match =flag1 statement =\{, flag1 line
        \{       flag1 equ
                match statement \\{ flag2 equ \\}
                match any,flag2 \\{ \}
        match =flag1 statement, flag1 line
        \{       flag1 equ
                match statement \\{ flag2 equ \\}
                match any,flag2 \}
}

mismatch =hello,hell ; work
{
display 'OK'
}
mismatch =hello2,hell ; work
{ display 'OK' }
mismatch =hello2,hell {
display 'OK' } ; error start from here
mismatch =hello2,hell { display 'OK'
}
mismatch =hello2,hell { display 'OK' }      


may be it could be realized internaly? (mismatch is simpler form of match: no replacement of params with pattern in inner block - only checking condition with inversed result)

_________________
I don`t like to refer by "you" to one person.
My soul requires acronim "thou" instead.


Last edited by ProMiNick on 14 Feb 2019, 17:45; edited 1 time in total
Post 14 Feb 2019, 16:41
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7310
Location: Kraków, Poland
I believe this can be macro-emulated in a much simpler way:
Code:
macro mismatch statement&
{
   local F
   F equ 1
   match statement \{ F equ 0 \}
   match F,F \{ rept F \}
}    
This, just like your macro, does not work if you put opening brace on the same line. But we can try to go fully insane:
Code:
macro mismatch line&
{
   local buffer,E,F
   define buffer line
   define F
   match e {, buffer \{ define E e
                        define F 1 { \}
   match e { f, buffer \{ define E e
                          define F 1 { f \}
   match , F \{ E equ buffer
                define F 1 \}
   match e, E \{ match e \\{ F equ 0*F \\} \}
   match f, F \{ rept f \}
}    
This ones seems to work with all your test cases.
Post 14 Feb 2019, 17:40
View user's profile Send private message Visit poster's website Reply with quote
ProMiNick



Joined: 24 Mar 2012
Posts: 353
Location: Russian Federation, Sochi
Tomasz, thanks. I don`t belived that it was possible via macros.
As allways thou could suprise me.
Post 14 Feb 2019, 17:54
View user's profile Send private message Send e-mail 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-2019, Tomasz Grysztar.

Powered by rwasa.