From: Wolfgang Kern on

Spam Killer wrote:

>> Well, but the CPU know only 16 variants.
>> So if your macro-engine accept double names you could save on almost
>> half of it.

> Condition codes as macro parameters aren't bad either. ;-) I saved 100
> lines! Do you see any errors? The "j%-1" inverts the conditions.

Good idea, if you can make sure that this macros are built during
compile time and not end up as self_modifying_code ...

I've a problem to check on this, because my binary/hex-world uses
percent signs only in commercial/financial/business statements :)

Workaround for inable tools can be done with DB-code substitution,
ie: condition codes 00..0f (all hex) can be added to

70 .. j'cc' (short) ;usually supported anyway
0f 40 .. cmov'cc'
0f 80 .. j'cc' (long)
0f 90 .. set'cc'

Perhaps your opposite desire can use db 70h (Jo) as base and just add
or 'or' the condition to it. Not sure if your tool can do expression
compilation on code bytes which the 'j%-1' seem to mean, but as I miss
the flag check in here, this may be an 'always predicted' solution ? ;)

__
wolfgang


> [list -]
> %macro cmovcc 3
> j%-1 %%skip
> mov %2,%3
> %%skip:
> %endmacro
>
> %imacro cmovo 2.nolist
> cmovcc O, %1, %2
> %endmacro
>
> %imacro cmovno 2.nolist
> cmovcc no, %1, %2
> %endmacro
>
> %imacro cmovc 2.nolist
> cmovcc c, %1, %2
> %endmacro
> %define cmovb cmovc
> %define cmovnae cmovc
>
> %imacro cmovnc 2.nolist
> cmovcc nc, %1, %2
> %endmacro
> %define cmovnb cmovnc
> %define cmovae cmovnc
>
> %imacro cmovz 2.nolist
> cmovcc z, %1, %2
> %endmacro
> %define cmove cmovz
>
> %imacro cmovnz 2.nolist
> cmovcc nz, %1, %2
> %endmacro
> %define cmovne cmovnz
>
> %imacro cmovna 2.nolist
> cmovcc na, %1, %2
> %endmacro
> %define cmovbe cmovna
>
> %imacro cmova 2.nolist
> cmovcc a, %1, %2
> %endmacro
> %define cmovnbe cmova
>
> %imacro cmovs 2.nolist
> cmovcc s, %1, %2
> %endmacro
>
> %imacro cmovns 2.nolist
> cmovcc ns, %1, %2
> %endmacro
>
> %imacro cmovpe 2.nolist
> cmovcc pe, %1, %2
> %endmacro
> %define cmovp cmovpe
>
> %imacro cmovpo 2.nolist
> cmovcc po, %1, %2
> %endmacro
> %define cmovnp cmovpo
>
> %imacro cmovl 2.nolist
> cmovcc l, %1, %2
> %endmacro
> %define cmovnge cmovl
>
> %imacro cmovnl 2.nolist
> cmovcc nl, %1, %2
> %endmacro
> %define cmovge cmovnl
>
> %imacro cmovng 2.nolist
> cmovcc ng, %1, %2
> %endmacro
> %define cmovle cmovng
>
> %imacro cmovg 2.nolist
> cmovcc g, %1, %2
> %endmacro
> %define cmovnle cmovg
> [list +]
> --
> wfz