flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > OR with match? |
Author |
|
hopcode 01 Feb 2010, 10:25
Hallo Azu,
in this way ~, so Code: macro @what arg{ define status 0 match =0 =this,status arg \{define status 1\} match =0 =is,status arg \{define status 1\} match =0 =an,status arg \{define status 1\} match =0 =example,status arg \{define status 1\} match =1,status\{display "success"\} } something equ an @what something something equ that @what something |
|||
01 Feb 2010, 10:25 |
|
Azu 01 Feb 2010, 10:35
Thank you
I meant a list of them on one line though Or is it not possible? |
|||
01 Feb 2010, 10:35 |
|
hopcode 01 Feb 2010, 10:37
or so,using if and list
Code: macro @what arg{ if arg in <this,is,an,example> display "success" end if } something equ an @what something something equ that @what something |
|||
01 Feb 2010, 10:37 |
|
Azu 01 Feb 2010, 10:40
Thanks!
I think it will only work for = (matching fixed string), though :\ Or does in have power of match? |
|||
01 Feb 2010, 10:40 |
|
hopcode 01 Feb 2010, 11:00
Azu wrote: I think it will only work for = (matching fixed string), though :\ Yes and no. If you mean a fixed list yes, if you mean strings, the mechanism is the same Code: macro @what arg{ if arg in <`this,`is,`an,`example> display "success" end if } something equ "an" @what something something equ "that" @what something Or you need to parse eqtype on arg Could you please explain it in details ? thanks . EDIT the same passing the fixed list Code: something equ "this","is","an","example" macro @what arg{ if arg in <something> display "success" end if } @what "this" ;success @what "that" ;no match @what "an" ;success or using irp with a preprocedural count could iterate thru the items, counting them, then repeat for each item a match for success or fail. . . |
|||
01 Feb 2010, 11:00 |
|
Azu 01 Feb 2010, 11:56
Oops! Sorry for the late response.
What I meant was having the features match does, such as not being limited to just matching against a constant string. E.G. it can use basic wildcards too. |
|||
01 Feb 2010, 11:56 |
|
hopcode 01 Feb 2010, 12:37
Azu wrote: ...the features match does, such as not being limited to just matching against a constant string. E.G. it can use basic wildcards too. I understand now. eqtype gives infos on the type of the the thing "any" corresponds to "*" in the match, but... it is not simple, and the difficulty is in the char-analyzing: virtual-ize a string and read char by char to find matches). In few words, each string should be splitted before matching. for example "this*ring", or "*ring". i searched for the hint-thread, but i cannot find it at the moment. Anyway (imho) i would not suggest any sort of string manipulation (like the splitting one), unless it is a symbol/label etc. (please guys, correct me if bad explained, thanks) Cheers, hopcode |
|||
01 Feb 2010, 12:37 |
|
Azu 01 Feb 2010, 13:02
Oh and also it should work in the preprocessor like match. I don't think you can use a macro of IFs and have it work at that stage, so I can't put equs in it like I can with match.. or am I overlooking something again?
|
|||
01 Feb 2010, 13:02 |
|
hopcode 01 Feb 2010, 13:38
Azu wrote: ..a macro of IFs and have it work at that... Yes,it is right as you said. Anyway, one could find a relative good solution when working between preprocedural/assembling stage, but not so good when the matter is content-string manipulation:even if possible,it is difficoult to break the following: mystring equ "mylabel123" in "mylabel" and "123" to make for example 2 assembled labels, namely mylabel: .123: or to use 123 as number One should use virtual on "mystring", load virtual chars, separate parts then create labels from those parts. |
|||
01 Feb 2010, 13:38 |
|
Borsuc 10 Feb 2010, 17:58
hopcode wrote: Hallo Azu, If you want all the match parameters on one line and use the preprocessor, use 'irp' to iterate through them: (if you want to have the 'literal' comma, you have to use '=\,' in irp, example below) Code: macro @what arg { define t irp m, =this, =is, =an, =example, a =\, b \{ match m, arg \\{ restore t define t + \\} \} match +,t \{ ; matched here \} restore t } This does the following: Code: macro @what arg { define t match =this, arg \{ restore t define t + \} match =is, arg \{ restore t define t + \} match =an, arg \{ restore t define t + \} match =example, arg \{ restore t define t + \} match a =, b, arg \{ restore t define t + \} match +,t \{ ; matched here \} restore t } _________________ Previously known as The_Grey_Beast |
|||
10 Feb 2010, 17:58 |
|
baldr 10 Feb 2010, 18:51
Borsuc,
There is another method to include comma in macro argument: enclose argument in <> (so a=\,b becomes <a=,b>). Backslashes' counting in macros is real hell. Indeed, your code expands to Code: ... match =example, arg \{ restore t define t + \} match a =, arg \{ ; !!!LOOK HERE!!! restore t define t + \} match b, arg \{ ; !!!LOOK HERE!!! restore t define t + \} match +,t \{ ; matched here \} ... |
|||
10 Feb 2010, 18:51 |
|
Borsuc 10 Feb 2010, 22:13
Ah yes you are correct. Thank you for the <> method, didn't know about it... will be very useful from now on
_________________ Previously known as The_Grey_Beast |
|||
10 Feb 2010, 22:13 |
|
bitRAKE 11 Feb 2010, 04:20
Matching an array of items. No current way to do string parsing with preprocessor (i.e. strings can only be broken into symbolic pieces).
|
|||
11 Feb 2010, 04:20 |
|
hopcode 12 Feb 2010, 02:30
fasm is very subtle...
i was testing this capability on the same line Code: macro @what arg{ match str,arg \{ irps s,str \\{ define negate 0 define comma 0 match =!,s \\\{ define negate 1 \\\} match =1 ==,negate s \\\{ display \\\`s ,13,10 \\\} match =,,s \\\{ display " ",\\\`s define comma 1 \\\} match =0 s1,comma s \\\{ display " ",\\\`s1 define comma 1 \\\} \\} display 13,10 \} } something equ "mystring", \ "is" != 0 if alfa += 9 / or alfa equ <X> @what something ;output ;mystring , is ! = 0 if alfa + = 9 or alfa equ < X > EDIT ";" (comment symbol) breaks the line . Regards, hopcode . |
|||
12 Feb 2010, 02:30 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.