flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > [Question] A macro that calculates

Author
Thread Post new topic Reply to topic
l4m2



Joined: 15 Jan 2015
Posts: 648
l4m2
Code:
macro calcu expr {
  match a p b, expr \{
    mov eax, a
    if (p) eq (+)
      add eax, b
    else if (p) eq (-)
      sub eax, b
    else if (p) eq (*)
      mul b
    else if (p) eq (/)
      div b
    else if (p) eq (%)
      div b
      mov edx, eax
    end if
  \}
}       
A simple macro calculating a op b and put the result into eax.
1) for equations like ecx*edx+ebx, an improved macro is required.
2) for (4+5)*eax, is it possible that 4+5 is calculated when compiling?
Post 13 Mar 2016, 05:41
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17287
Location: In your JS exploiting you and your system
revolution
l4m2 wrote:
2) for (4+5)*eax, is it possible that 4+5 is calculated when compiling?
Yes.
Post 13 Mar 2016, 06:52
View user's profile Send private message Visit poster's website Reply with quote
l4m2



Joined: 15 Jan 2015
Posts: 648
l4m2
"irps x, 2*(3+5)" splits it into 2, *, (, 3, +, 5, ). Therefore blanket matching needed to be done in the code
Post 13 Mar 2016, 13:27
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17287
Location: In your JS exploiting you and your system
revolution
You can use "match" for more sophisticated expressions.
Post 13 Mar 2016, 13:41
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.