I probably some times the simple things are not real, but I learned it can be true!...
Subjecting my brain space trying to figure out how can I make a DEFINE macro recognize from char symbols, words or numbers to apply an alias to.
Some days I came with:
IFNDEF DEFINE
DEFINE MACRO DefName:REQ, defargs:VARARG
LOCAL DEFINEover, DEFINEFORCover
deffnex TEXTEQU <>
deffnex CATSTR deffnex, <&DefName& >
IFB <defargs>
deffnex CATSTR deffnex, <EQU 1>
ELSE
FORC charin,<defargs>
IFB <charin>
GOTO DEFINEFORCover
ELSEIFIDN <charin>, < >
GOTO DEFINEFORCover
ELSEIFIDN <charin>, <_>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <@>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <?>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <A>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <B>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <C>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <D>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <E>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <F>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <G>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <H>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <I>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <J>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <K>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <L>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <M>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <N>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <O>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <P>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <Q>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <R>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <S>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <T>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <U>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <V>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <W>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <X>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <Y>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <Z>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <a>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <b>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <c>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <d>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <e>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <f>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <g>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <h>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <i>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <j>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <k>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <l>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <m>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <n>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <o>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <p>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <q>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <r>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <s>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <t>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <u>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <v>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <w>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <x>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <y>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <z>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <'>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <">
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <0>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <1>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <2>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <3>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <4>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <5>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <6>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <7>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <8>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ELSEIFIDN <charin>, <9>
deffnex CATSTR deffnex, <EQU defargs>
EXITM
ENDIF
:DEFINEFORCover
ENDM
ENDIF
deffnex
ENDM
ENDIF
Some steps debugin my code in minutes I came with:
IFNDEF DEFINE
DEFINE MACRO DefName:REQ, defargs:VARARG
deffnex TEXTEQU <>
deffnex CATSTR deffnex, <&DefName& >
IFB <defargs>
deffnex CATSTR deffnex, <EQU 1>
ELSE
deffnex CATSTR deffnex, <EQU defargs>
ENDIF
deffnex
ENDM
ENDIF
IFNDEF DEFINED
DEFINED MACRO defarg:REQ
LOCAL earg
earg = 0
IFDEF defarg
earg = 1
ENDIF
EXITM <earg GE 1>
ENDM
ENDIF
externdef __m128i_i32_true:__m128i
DEFINE M128I32TRUE, __m128i_i32_true
DEFINE EG4, 0X4
IF DEFINED(M128I32TRUE)
DEFINE MYM128I32TRUE, M128I32TRUE
ENDIF
IF DEFINED(EG4)
DEFINE MYEG4, EG4
ENDIF
Cannot get simpler... :shhh:
More simple is possible.
HERE IS THE ONE i USED IN THE TRANSLATED sdk
Quote
NOTDEFINED MACRO symbol
IFNDEF symbol
EXITM <-1>
ELSE
EXITM <0>
ENDIF
ENDM
DEFINED MACRO symbol
IFDEF symbol
EXITM <-1>
ELSE
EXITM <0>
ENDIF
ENDM
COMPARE MACRO constant,argument,value
IFDEF constant
IF constant argument value
EXITM <-1>
ELSE
EXITM <0>
ENDIF
ELSE
EXITM <0>
ENDIF
ENDM
#TouEnMasm :thumbsup:
Added textequates.
IFNDEF DEFINE
DEFINE MACRO DefName:REQ, defargs, textargs
deffnex TEXTEQU <>
deffnex CATSTR deffnex, <&DefName& >
IFB <textargs>
IFB <defargs>
deffnex CATSTR deffnex, <EQU 1>
ELSE
deffnex CATSTR deffnex, <EQU defargs>
ENDIF
ELSE
deffnex CATSTR deffnex, <TEXTEQU <defargs>>
ENDIF
deffnex
ENDM
ENDIF
DEFINE reg0, xmm0, text
Manual translating vcruntime and windows kit sdk... :sad:..
a little complex for me.
I used a more simple one.
Quote
UneChaine TEXTEQU <"Hello"> ;UneChaine is DEFINED
UneChaine equ ;UneChaine begin with no value but is already defined
UneChaine equ <QWORD> ;UneChaine change Value
UneChaine couldn't become Undefined now
I'm not quite sure what is the purpose of certain macros :rolleyes:
include \masm32\include\masm32rt.inc
DEFINED MACRO symbol
IFDEF symbol
EXITM <-1>
ELSE
EXITM <0>
ENDIF
ENDM
.code
start:
ifdef bla
echo bla is defined
else
echo bla is undefined
endif
if DEFINED(bla)
echo bla is defined
else
echo bla is undefined
endif
bla equ <>
ifdef bla
echo bla is defined
else
echo bla is undefined
endif
if DEFINED(bla)
echo bla is defined
else
echo bla is undefined
endif
exit
.err
end start
Output:
bla is undefined
bla is undefined
bla is defined
bla is defined
Those macros (DEFINED and NOTDEFINED) are not to made a single coomparison,they are useless in this case,but to be use
in chained expressions like this.
Quote
IF NOTDEFINED(_68K_) AND NOTDEFINED(_MPPC_) AND NOTDEFINED(_X86_) AND NOTDEFINED(_IA64_) AND NOTDEFINED(_AMD64_) AND NOTDEFINED(_ARM_) AND NOTDEFINED(_ARM64_) AND DEFINED(_M_ARM64)
Here they are usefull and couldn't be replace