flat assembler
Message board for the users of flat assembler.

Index > Main > Macro if val *

Author
Thread Post new topic Reply to topic
Roman



Joined: 21 Apr 2012
Posts: 1792
Roman 28 Jun 2013, 15:03
how to Compare val and *?

My macro :
macro FioMul chs {
match d1\d2\d3 , chs
\{
if `d2 eqtype `+
invoke MessageBox,0,"2+4",'o',0
else if `d2 eqtype *
invoke MessageBox,0,"2*4",'o',0
end if
\}
}

FioMul 2\*\4 (get MessageBox,0,"2+4",'o',0)
But if i do FioMul 2\+\4 (i get MessageBox,0,"2+4",'o',0)
Post 28 Jun 2013, 15:03
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20339
Location: In your JS exploiting you and your system
revolution 28 Jun 2013, 23:42
If you want to compare values then use = or eq instead of eqtype. Also the backslashes in the second level match will be stripped by the outer match, it might be better to use another separator character.
Post 28 Jun 2013, 23:42
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1792
Roman 30 Jun 2013, 19:06
revolution "compare values then use = or eq instead of eqtype"
did not help
Post 30 Jun 2013, 19:06
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4042
Location: vpcmpistri
bitRAKE 30 Jun 2013, 20:00
This worked for me:
Code:
macro FioMul chs {
  match d1\d2\d3 , chs \{
    if \`d2  = `+
      display "2+4",13,10
    else if \`d2 = '*'
      display "2*4",13,10
    end if
  \}
}
FioMul  2\*\4
FioMul  2\+\4    
...there were two errors.

A) need to escape ` operator to depth of usage with blackslash.
(this delays evaluation until d# has correct value)

B) character values are being compared but you have used symbol *.
(valid methods are `* and '*')

Hopefully, repeating her/his advise helps.
Post 30 Jun 2013, 20:00
View user's profile Send private message Visit poster's website Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1792
Roman 01 Jul 2013, 05:14
bitRAKE
Thanks dude. Respect
Post 01 Jul 2013, 05:14
View user's profile Send private message Reply with quote
Roman



Joined: 21 Apr 2012
Posts: 1792
Roman 01 Jul 2013, 05:30
This macro work fine (FioMul 2*4 or FioMul 2+4)
macro FioMul chs { match d1\d2\d3 , chs \{
if \`d2 = `+
invoke MessageBox,0,"2+4",'o',0
end if
if \`d2 = `*
invoke MessageBox,0,"2*4",'o',0
end if \} }

But if i want write this:
FioMul 2+3*4+5-7*2+1+2 or i want write FioMul 2+34+57*21+2
How to make a FioMul macro to take this all values and ganerate right code ?
Post 01 Jul 2013, 05:30
View user's profile Send private message Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 4042
Location: vpcmpistri
bitRAKE 01 Jul 2013, 06:44
You would need to read about how an expression parser works. There are many good tutorials online. There are many good examples on the board here.

A simplistic way would be to break the expression into a series of <op> <val> pairs. We would ignore operator precedence and handle them in order.

This might not be sufficient though - depending on your ultimate goal.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 01 Jul 2013, 06:44
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


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.