I find it hard to write macros.
For example this macro
TESTING MACRO args:VARARG
LOCAL buffer
buffer equ <>
forc char,<args>
buffer CATSTR buffer,<char>
endm
exitm <buffer>
ENDM
%echo TESTING("!") ; = ""
%echo TESTING("\") ; = ""
%echo TESTING("\\") ; = "\"
%echo TESTING("<>") ; = ""
The "\" could be written with an escape char "\\" but how do i write the macro to accept the other characters?
Hi,
You can try the escape character. But it isi probably
easier to use hexadecimal/numeric representations
of those characters.
Regards,
Steve N.
Try this...
include \masm32\include\masm32rt.inc
TESTING MACRO args:VARARG
LOCAL buffer, tmpL$, tmpR$, is
buffer equ <args>
is INSTR <args>, <!!>
if is
tmpL$ SUBSTR <args>, 1, is-1
tmpR$ SUBSTR <args>, is+1
buffer CATSTR tmpL$, <!!>, tmpR$
endif
is INSTR <args>, <!<>
if is
tmpL$ SUBSTR <args>, 1, is-1
tmpR$ SUBSTR <args>, is+1
buffer CATSTR tmpL$, <!<>, tmpR$
endif
is INSTR <args>, <!>>
if is
tmpL$ SUBSTR <args>, 1, is-1
tmpR$ SUBSTR <args>, is+1
buffer CATSTR tmpL$, <!>>, tmpR$
endif
exitm <buffer>
ENDM
.code
start:
% echo TESTING("!!") ; = ""
% echo TESTING("\ (impossible)") ; = ""
% echo TESTING("\\") ; = "\"
% echo TESTING("<>") ; = ""
.err
exit
end start