flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Macroinstructions > Matching {

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 591
Matching {

Code:
macro xxx [x] {
  common
  match a =\{ bx \{
    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
Assembly Artist


Joined: 16 Jun 2003
Posts: 6599
Location: Kraków, Poland
When evaluating outer macro, the "match" line becomes:

Code:
match a ={ b2 { 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 =\{ by \{
    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 \{ by \{
    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: 591

Code:
macro xxx x& {
  local y
  y equ x 
  match a \{ by \{
    match atest 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: 591

Code:
macro xxx x& {
  local yqt
  y equ x 
  match =q a \{ bq y \{
    q equ
    s equ a
    t equ b
  \}
  match =q a \{  , q y \{
    q equ
    s equ a
    t equ
  \}
  match stest 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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.