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 > operand metadata 1 : Error: invalid expression

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 421
Location: Belarus
operand metadata 1 : Error: invalid expression
Below is a working example, where I get error on the 3rd and 4th calls. Cannot understand why this happens. What am I missing? Why does match miss the correct block?


Code:

define op

macro call? dest*
  local operandsizetypeprefixes
  define operand dest

  type = 1
  match =near? moredest
    type = 1
    redefine operand more
  else match =far? moredest
    type = 2
    redefine operand more
  end match

  parse_operands typeoperand
end macro

macro parse_operands t:0operands*&
  local operandsize

  irp opsoperands
    define operand ops
    size = 0
    match =tbyte? moreops
      size = 10
      redefine operand more
    end match
    parse_operand operand
  end irp
end macro

macro parse_operand operand*
  local m
  match segment:offsetoperand
    match [addr], offset
      display 'wrong',13,10
    else
      display 'wrong',13,10
    end match
  else match [addr], operand
    display 'CORRECT!',13,10
  else
    m = operand metadata 1
    display 'wrong',13,10
  end match
end macro

element rax? : 1

call tbyte [rax]
call far tbyte [rax]
call far [rax]
call [rax]


Post 21 Mar 2017, 20:14
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6192
Location: Kraków, Poland
When "parse_operand" receives the symbolic variable as a parameter, this line:

Code:
    define operand ops

defines a symbolic variable that contains just the identifier of the one defined by the outer macro (because DEFINE does not evaluate symbolic values). To extract the text from the variable you could just use EQU instead:

Code:
    operand equ ops

since EQU does replace symbolic variable with their values (this is just like in fasm 1). Or, alternatively, you could rewrite the entire sequence:

Code:
    match =tbyte? moreops
      size = 10 
      redefine operand more
    else match anyops
      size = 0
      define operand any
    end match

Post 21 Mar 2017, 20:29
View user's profile Send private message Visit poster's website 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.