flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > adding '.then' to the .if macro

Author
Thread Post new topic Reply to topic
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
how would I add a '.then' to the '.if' macro?

This is how it would look:
Code:
.if rax = NULL .then call Error    

or:
Code:
.if rax = NULL .then invoke  MessageBox, 0, "RegisterClassEx()", "ERROR", MB_OK or MB_ICONERROR    

_________________
Gimme a sledge hammer! I'LL FIX IT!
Post 28 Jun 2013, 17:31
View user's profile Send private message Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
Wouldn't it be the same as the opposite of else? I think you can resolve it to a continuation of the .if statement.

Code:
macro .then [_cmd]
{
    if ~defined .if
       error 'then without if' 
    else
       ; this is where you resolve it
       _cmd
    endif   
}
    


Not an expert in this field. Just a suggestion
Post 29 Jun 2013, 00:43
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17280
Location: In your JS exploiting you and your system
revolution
You can't process two macros on the same line. You would have to modify the .if macro to recognise .then and act accordingly.

Note that inline macros are possibly going to be in fasm2
Post 29 Jun 2013, 00:47
View user's profile Send private message Visit poster's website Reply with quote
bitRAKE



Joined: 21 Jul 2003
Posts: 2915
Location: [RSP+8*5]
bitRAKE
Here is one way (quick hack):
Code:
macro .if [arg]
{
  common
  __IF equ
  local ..endif
  __ENDIF equ ..endif
  local ..else
  __ELSE equ ..else

  __THEN equ
  match A =.then B,arg \{
    JNCOND __ELSE,A
    B
    .endif

    restore __THEN
    __THEN equ ,
  \}

  match ,__THEN \{
    JNCOND __ELSE,arg
  \}

  restore __THEN
}    
It all happens on the preprocessor side of things, so it might be a good general solution. BTW, thanks for making your work public, madmatt.

_________________
¯\(°_o)/¯ unlicense.org
Post 29 Jun 2013, 02:23
View user's profile Send private message Visit poster's website Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
bitRAKE wrote:
Here is one way (quick hack):
Code:
macro .if [arg]
{
  common
  __IF equ
  local ..endif
  __ENDIF equ ..endif
  local ..else
  __ELSE equ ..else

  __THEN equ
  match A =.then B,arg \{
    JNCOND __ELSE,A
    B
    .endif

    restore __THEN
    __THEN equ ,
  \}

  match ,__THEN \{
    JNCOND __ELSE,arg
  \}

  restore __THEN
}    
It all happens on the preprocessor side of things, so it might be a good general solution. BTW, thanks for making your work public, madmatt.


That worked great. Wish I knew macro programming this good.
"BTW, thanks for making your work public"
No problem, always will be free and public.

_________________
Gimme a sledge hammer! I'LL FIX IT!
Post 29 Jun 2013, 13:23
View user's profile Send private message 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.