flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > labeling procs for debug & <> braces

Author
Thread Post new topic Reply to topic
edemko



Joined: 18 Jul 2009
Posts: 549
edemko
Code:
;nok
macro proc [args]{
  common
    match name params, args\{
      if used name
        db 0,'proc ', `name, 0
        define@proc name, <params>
      end if
    \}
}


;ok
macro proc [args]{
  common
    match name params, args>\{
      if used name
        db 0,'proc ', `name, 0
        define@proc name, <params
      end if
    \}
}


;Are not both equal?
    
Post 30 Nov 2010, 08:36
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
In first case it is not possible to have only name and no parameters - because "name params" need to match at least two elements (one for "name" and one for "params"), and if only name is provided, the match will not happen.
In second case the ">" artificially provides something to match the "params" even when there is only name provided.
Post 06 Dec 2010, 14:03
View user's profile Send private message Visit poster's website Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko
Thank you.

Macro below was expected to show procedure name.
It does not.
As i know "match name params" denotes local constants.
That's why "display `name" used.
But "namename" visible instead of "p1p2".
Am i wrong here too?
Code:
macro proc [args]{
  common
    match name params, args>\{
      display `name
      define@proc name, <params
    \}
}


proc p1
endp

proc p2
endp

    
Post 18 Dec 2010, 18:25
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
` operator is processed by the outer macro, so it converts the "name" token into string. To make it processed by the inner macro (the "match" one) you need to escape it with backslash:
Code:
display \`name    
Now it will convert into string the first token that is there after replacement of "name" with its matched value.
Post 18 Dec 2010, 18:54
View user's profile Send private message Visit poster's website Reply with quote
edemko



Joined: 18 Jul 2009
Posts: 549
edemko
appreciate that, thanks, final macro:
Code:
macro proc [args]{
  common
    match name params, args>\{
      if used \name
        db 0,'proc ',\`name,0
        define@proc \name, <\params
      end if
    \}
}
    
Post 19 Dec 2010, 07:33
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.

Powered by rwasa.