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 > [fasmg] question about matching

Author
Thread Post new topic Reply to topic
zhak



Joined: 12 Apr 2005
Posts: 419
Location: Belarus
[fasmg] question about matching
Let's say I define data types as

Code:

byte      ; the same as rb 1
byte [?; the same as rb 1
byte [3; the same as rb 3
byte [45 ; the same as db 4 dup 5
etc.



Also, I add naturally aligned data types as

Code:

aligned word
aligned dword [4]
etc.




For this aligned types I use struc

Code:

struc aligned? args&
  match =byte?args
    label .
    byte [1]
  else match =byte? moreargs
    label .
    byte more
  else match =word?args
    align 2
    label .
    word [1]
  else match =word? moreargs
    align 2
    label .
    word more
  end match
end struc



Here I must always match two variants: if data type has parameters following it or not.
Is it possible to somehow match only the beginning of the string so that it doesn't matter if 'more' is empty or not?
Post 12 Feb 2017, 15:52
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 6179
Location: Kraków, Poland
Re: [fasmg] question about matching

zhak wrote:
Is it possible to somehow match only the beginning of the string so that it doesn't matter if 'more' is empty or not?

While MATCH does not allow to match names with empty content, it is usually possible to deal with this using some tricks, though that may depend on context. For example:

Code:
    match =word? moreargs :
        align 2
        label .
        match value :, more
                word value
        else
                word [1]
        end match
    end match

Post 12 Feb 2017, 16:14
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.