flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > .if .and .endif

Author
Thread Post new topic Reply to topic
eet_1024



Joined: 22 Jul 2003
Posts: 59
eet_1024 25 Oct 2003, 00:07
I've butchered IF.INC to provide a .and macro. This macro is chainable.
Code:
macro .and v1,c,v2
{
  if v2 eq & c eq
   cmp v1,0
   je __ELSE
  else if v1 eq & v2 eq
   jn#c __ELSE
  else
   cmp v1,v2
   jn#c __ELSE
  end if
}
    


Useage:
Code:
.if   eax
; You can place code here that will execute if eax != 0
.and ebx
; Code here only executes if (eax != 0) and (ebx !=0)
.and ecx, e, 5
; Code here only executes if (eax != 0) and (ebx !=0) and (ecx == 5)
.elseif  ; optional
.else  ; optional
.endif
    


I couldn't figure out how to do .or. But I believe it needs to invert condition of the jumps in the previous .if/.and/.or and have that jump target past the cmp of this .or declaration.

That is so shortcircuiting and chaining work.

Privalov:
Code:
  local ..else          ; What is this for
  __ELSE:
  restore __ELSE
  __ELSE equ ..else     ; And this
    

Code:
macro .endif
{
  if __IF eq   ; Is this required?
   __ELSE:
  end if
    
Post 25 Oct 2003, 00:07
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.