flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > Matching {

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 648
l4m2
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 {.
Post 06 Aug 2016, 15:25
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7725
Location: Kraków, Poland
Tomasz Grysztar
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 }    
Post 06 Aug 2016, 16:21
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 648
l4m2
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
Post 06 Aug 2016, 16:56
View user's profile Send private message Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 648
l4m2
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\}}    
Post 06 Aug 2016, 17:24
View user's profile Send private message 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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.