Author Topic: Is it possible to make alternative macro?  (Read 1648 times)

daydreamer

  • Member
  • *****
  • Posts: 2399
  • my kind of REAL10 Blonde
Is it possible to make alternative macro?
« on: November 30, 2021, 01:11:01 AM »
Alternative macro similar to. If. Else.endif
But when using test different bits?
my none asm creations
http://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

  • Member
  • *****
  • Posts: 2502
  • AMD 7-32 / i3 10-64
Re: Is it possible to make alternative macro?
« Reply #1 on: November 30, 2021, 03:09:58 AM »
No problem, I think.

See Hutch's macros in masm64.

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

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Is it possible to make alternative macro?
« Reply #2 on: November 30, 2021, 07:21:00 AM »
Code: [Select]
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

  • Member
  • *****
  • Posts: 2502
  • AMD 7-32 / i3 10-64
Re: Is it possible to make alternative macro?
« Reply #3 on: November 30, 2021, 08:25:06 AM »
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:
Code: [Select]
__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:
Code: [Select]
        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

  • Member
  • *****
  • Posts: 2399
  • my kind of REAL10 Blonde
Re: Is it possible to make alternative macro?
« Reply #4 on: November 30, 2021, 12:52:04 PM »
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
http://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

  • Member
  • *****
  • Posts: 2502
  • AMD 7-32 / i3 10-64
Re: Is it possible to make alternative macro?
« Reply #5 on: November 30, 2021, 01:23:48 PM »
 :biggrin: Just a translation from C++.
Equations in Assembly: SmplMath

daydreamer

  • Member
  • *****
  • Posts: 2399
  • my kind of REAL10 Blonde
Re: Is it possible to make alternative macro?
« Reply #6 on: November 30, 2021, 08:43:04 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
http://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

  • Member
  • *****
  • Posts: 2794
Re: Is it possible to make alternative macro?
« Reply #7 on: December 01, 2021, 03:13:53 AM »
Alternative macro similar to. If. Else.endif
But when using test different bits?

Why would you need alternative macros?

daydreamer

  • Member
  • *****
  • Posts: 2399
  • my kind of REAL10 Blonde
Re: Is it possible to make alternative macro?
« Reply #8 on: December 12, 2021, 09:03:11 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
http://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