flat assembler
Message board for the users of flat assembler.
 flat assembler > Macroinstructions > Matching {
Author
l4m2

Joined: 15 Jan 2015
Posts: 611

# Matching {

 Code: macro xxx [x] {   common   match a =\{ b, x \{     err   \} } xxx 3 { nop }
I want to split 3 { nop } into 3 and {nop} but it says Illegal instruction at {.
06 Aug 2016, 15:25
Tomasz Grysztar
Assembly Artist

Joined: 16 Jun 2003
Posts: 6817
Location: Kraków, Poland
When evaluating outer macro, the "match" line becomes:
 Code: match a ={ b, 2 { nop } {
and then the "{ nop }" becomes interpreted as the content of the "match" block, with additional "{" after the block.
You can get around this problem by defining a temporary symbolic variable to hold matched value:
 Code: macro xxx [x] {   common local y   y equ x   match a =\{ b, y \{     err   \}  }  xxx 3 { nop }

On a side note, you don't have to use "=" to match "{". And instead of using repeatable argument and "common" block, you can used the new syntax with "&":
 Code: macro xxx x& {   local y   y equ x   match a \{ b, y \{     err   \}  }  xxx 3 { nop }
06 Aug 2016, 16:21
l4m2

Joined: 15 Jan 2015
Posts: 611
 Code: macro xxx x& {   local y   y equ x    match a \{ b, y \{     match a, test 1     b   \}   }   xxx =test any { nop   nop }
makes an unexpected characters
06 Aug 2016, 16:56
l4m2

Joined: 15 Jan 2015
Posts: 611
 Code: macro xxx x& {   local y, q, t   y equ x    match =q a \{ b, q y \{     q equ     s equ a     t equ b   \}   match =q a \{  , q y \{     q equ     s equ a     t equ   \}   match s, test 1 \{   t } ;This works fine xxx =test any  { rept 3 i:48 \{display i\}} ;But not this xxx =test any  {rept 3 i:48 \{display i\}}
06 Aug 2016, 17:24
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------Blog General----------------MainDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsCompiler InternalsIDE DevelopmentOS ConstructionNon-x86 architecturesHigh Level LanguagesProgramming Language DesignProjects and IdeasExamples and Tutorials Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum