News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Is it possible to make alternative macro?

Started by daydreamer, November 30, 2021, 01:11:01 AM

Previous topic - Next topic

daydreamer

Alternative macro similar to. If. Else.endif
But when using test different bits?
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

HSE

No problem, I think.

See Hutch's macros in masm64.

More powerful, and complex, are Mabdelouabad macros.
Equations in Assembly: SmplMath

jj2007

include \masm32\include\masm32rt.inc ; plain Masm32 for the fans of pure assembler

.code

start:
  mov eax, 3
  .if eax & 4
inkey "bit 2 is set"
  .else
inkey "bit 2 is not set"
  .endif
exit

end start

HSE

Here I'm using "cmp", but you can modify macros and use "test". Hutch's macros are more clear but you can make only 20 levels  :biggrin:, with this You can use any number of levels.

This are simplified macros:__if_ttt_n0 = 0
__if_ttt_level = 0

__if_ttt_resuelve macro m1, a1, a2
% &m1
% cmp &a1, 0
ifnb <&a2>
jg @CatStr(__if_ttt_,%__if_ttt_n0,<_>,%__if_ttt_level,%__if_ttt_n1)
else
je @CatStr(__if_ttt_,%__if_ttt_n0,<_>,%__if_ttt_level,%__if_ttt_n1)
endif
endm

@if macro m1, a1, a2
if __if_ttt_level eq 0
__if_ttt_n0 = __if_ttt_n0 + 1
endif
__if_ttt_level = __if_ttt_level + 1
__if_ttt_n1 = 0
__if_ttt_resuelve <&m1>, &a1, &a2
endm

@elseif macro m1, a1, a2
jmp @CatStr(__if_ttt_,%__if_ttt_n0,<_>,%__if_ttt_level)
@CatStr(__if_ttt_,%__if_ttt_n0,<_>,%__if_ttt_level,%__if_ttt_n1,<:>)
;% &m1

__if_ttt_n1 = __if_ttt_n1 + 1
__if_ttt_resuelve <&m1>,&a1, &a2

endm

@else macro
jmp @CatStr(__if_ttt_,%__if_ttt_n0,<_>,%__if_ttt_level)
@CatStr(__if_ttt_,%__if_ttt_n0,<_>,%__if_ttt_level,%__if_ttt_n1,<:>)
__if_ttt_n1 = __if_ttt_n1 + 1
endm

    __if_ttt_setEnd macro
        @CatStr(__if_ttt_,%__if_ttt_n0,<_>,%__if_ttt_level,<:>)
    endm
@endif macro
@CatStr(__if_ttt_,%__if_ttt_n0,<_>,%__if_ttt_level,%__if_ttt_n1,<:>)
__if_ttt_setEnd
if __if_ttt_level gt 0
__if_ttt_level = __if_ttt_level - 1
endif
endm


Must be used:        mov eax, clipUnion
        and eax, POLYGON_CLIP_RIGHT
        ;int 3
            @if <>, eax
                     ***************
    cond1 macro
           DbgText "test 2"
   mov eax, clipUnion
   and eax, POLYGON_CLIP_LEFT
   ;int 3
    endm

            @elseif <cond1>, eax
                    ************************

            cond1 macro
                mov eax, POLYGON_CLIP_RIGHT
            or eax, POLYGON_CLIP_LEFT
            and eax, clipSum 
            endm
            @elseif <cond1>, eax, 0
                   **************     

           @else
                ************
            @endif





A more complex thing using Mabdelouahab's macros is in if-elseif Mab's macros for floating comparisons

PD: just in case. The smile about 20 levels is that is a lot  :biggrin: I think I used at most 6 levels.
Equations in Assembly: SmplMath

daydreamer

thanks JJ,Hector :thumbsup:
polygonclip code,why not SSE solution?
its similar solution to packed compare which returns either FFFF or zero which you can shift and use AND,OR,XOR to check .IF variable>left and variable<right
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

HSE

Equations in Assembly: SmplMath

daydreamer

Quote from: HSE on November 30, 2021, 01:23:48 PM
:biggrin: Just a translation from C++.
That's the usual approach to learn some new algo
First you research and find some hll example, first get it working right
After that optimize when you understand how it works

my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

Vortex

Quote from: daydreamer on November 30, 2021, 01:11:01 AM
Alternative macro similar to. If. Else.endif
But when using test different bits?

Why would you need alternative macros?

daydreamer

Quote from: Vortex on December 01, 2021, 03:13:53 AM
Quote from: daydreamer on November 30, 2021, 01:11:01 AM
Alternative macro similar to. If. Else.endif
But when using test different bits?

Why would you need alternative macros?
thanks to JJ I dont need bit testing macro :thumbsup:
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding