flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > irp-macro invalid

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 648
l4m2
Code:
irp ty, db, dw, dd, dq {
  macro ty a, [b] \{
    common
    if `a == 'byte'
      db b
    else if `a == 'word'
      dw b
    else if `a == 'dword'
      dd b
    else if `a == 'qword'
      dq b
    else
      ty a b
    end if
  \}
  macro ty [args] \{
    forward
    match a b, args \\{
      ty a, b
    \\}
  \}
}
dd word 3, 4    
Post 16 Jul 2016, 04:40
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7721
Location: Kraków, Poland
Tomasz Grysztar
You need to escape "common", "forward", and "`" too. Otherwise they are processed by the "irp" macro instead of becoming part of the inner ones.
Code:
irp ty, db, dw, dd, dq {
  macro ty a, [b] \{
    \common
    if \`a = 'byte'
      db b
    else if \`a = 'word'
      dw b
    else if \`a = 'dword'
      dd b
    else if \`a = 'qword'
      dq b
    else
      ty a b
    end if
  \}
  macro ty [args] \{
    \forward
    match a b, args \\{
      ty a, b
    \\}
  \}
}    
Post 16 Jul 2016, 07:24
View user's profile Send private message Visit poster's website Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7721
Location: Kraków, Poland
Tomasz Grysztar
I may also suggest a bit different approach:
Code:
irp ty, db, dw, dd, dq {
  macro ty [args] \{
      if 0
    match a b, args \\{
      else if a eq byte
        db b
      else if a eq word
        dw b
      else if a eq dword
        dd b
      else if a eq qword
        dq b
    \\}
      else
        ty args
      end if
  \}
}

dd word 3, 4    
Post 16 Jul 2016, 08:15
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 648
l4m2
Okay I wanted to make PUSH QWORD 3 compied into PUSH DWORD 3 DWORD 0 but even with the macro seem not so easy
Post 25 Jul 2016, 11:04
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.