flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Easier conditional jumps with .if and .endif macroses |
Author |
|
Tomasz Grysztar 09 Feb 2005, 22:03
Similar macros are already provided with the FASMW package in INCLUDE\MACRO\IF.INC file.
|
|||
09 Feb 2005, 22:03 |
|
Reverend 09 Feb 2005, 22:14
Yes I know there are similar macroses. But afaik they do not allow many conditions being checked in one statement (I mean in one line of code). Also my macro checks a special case, as I said above. And imho seeing ".if eax equal 100" in sourcecode is more readfriendly (? hehe. nice word ) than ".if eax,z,100"
I forgot to say also before that my macro will correctly interpret nested .if: Code: .if eax equal 0 call SOME_PROCEDURE .if edx more_equal 0 call IF_ALL_CONDITIONS_WERE_MET .endif .endif |
|||
09 Feb 2005, 22:14 |
|
Vasilev Vjacheslav 19 Feb 2005, 15:14
Reverend, i modify a bit your macro, but because i am a beginner in macroses i made many mistakes (i think). PLEASE, If somebody can - check for errors this code:
Code: macro .if [v1,c,v2] { common local __endif local __else forward if v1 in <eax,ebx,ecx,edx,esi,edi,ebp,esp> & v2 eq 0 test v1,v1 jn#c __else else cmp v1,v2 jn#c __else end if common __pif equ __pendif equ __endif __pelse equ __else } macro .else { jmp __pendif __pelse: restore __pif __pif equ , } macro .elseif [v1,c,v2] { common local __else jmp __pendif __pelse: restore __else forward if v1 in <eax,ebx,ecx,edx,esi,edi,ebp,esp> & v2 eq 0 test v1,v1 jn#c __else else cmp v1,v2 jn#c __else end if common __pelse equ __else } macro .endif { if __pif eq __pelse: end if __pendif: restore __pelse restore __pendif restore __pif } jnnz equ jz jnne equ je jnna equ ja jnnb equ jb jnng equ jg jnnl equ jl jnnae equ jae jnnbe equ jbe jnnge equ jge jnnle equ jle _________________ [not enough memory] |
|||
19 Feb 2005, 15:14 |
|
RedGhost 20 May 2005, 09:55
haha, i made my own before i even knew if statements came with fasm as macros in the default package
anyways both of yours are much better than mine, nj |
|||
20 May 2005, 09:55 |
|
Reverend 23 May 2005, 20:58
As the topic got renewed I may add something from me. Does anybody know the way to check what is the next instruction? Or is it possible at all? I mean when...:
Code: .if eax, a, 100 add eax, 100 .if eax, a, 300 sub eax, 50 .endif .endif When compiler builds such code it produces unnecessary jmps in place where two .endifs are next to other. It's two byte on every conditional check, and it also slows program a bit, when using it in some kind of inner loop of some big algorithm. So I ask, if there's a possibility to check whether the next instruction is .endif and if so, omit assembling unnecessary jump? Am I clear enough? |
|||
23 May 2005, 20:58 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.