Ive recenty been going through the macros.asm file trying to come across some handy macros I can implement into my projects to save time.
When would I use say a "SADD" macro as opposed to a "CTXT" or even "literal" one.
; ---------------------
; literal string MACRO
; ---------------------
literal MACRO quoted_text:VARARG
LOCAL local_text
.data
local_text db quoted_text,0
align 4
.code
EXITM <local_text>
ENDM
; --------------------------------
; string address in INVOKE format
; --------------------------------
SADD MACRO quoted_text:VARARG
EXITM <ADDR literal(quoted_text)>
ENDM
; --------------------------------
; string OFFSET for manual coding
; --------------------------------
CTXT MACRO quoted_text:VARARG
EXITM <offset literal(quoted_text)>
ENDM
Similiarly with nesting function calls inside function calls, im uncertain of the differences between the following two MACROS. If someone, anyone, could shed the light for me that would be great;
Quote; ----------------------------
; function return value macro
; ----------------------------
RV MACRO args:VARARG
args
EXITM <eax>
ENDM
; ------------------------------------------------------------
; Macro for nesting function calls in other invoke statements
; ------------------------------------------------------------
FUNC MACRO parameters:VARARG
invoke parameters
EXITM <eax>
ENDM
SADD returns the ADDR of a string. It can only be used as a parameter of an INVOKE. CTXT returns the offset to a string. It can be used anywhere. Invoke is happy to accept offsets to strings, so I can't think of any reason to use something that returns the ADDR of a string unless there is some subtle parameter checking going on. I use my own version of CTXT for everything so it doesn't conflict with macros.asm-
soff Macro QuotedText:Vararg ; returns offset to a string
Local LocalText
.data
LocalText db QuotedText,0
.code
EXITM <offset LocalText>
Endm
I hate typing strings of upper case letters :wink
I'm sure someone will jump in with the real reason to use ADDR.
For RV, (return value?,) the parameters must contain the action (e.g. invoke) whereas FUNC accepts only parameters for an invoke.
Ksbunker,
There is a trick with the masm32 macros, read the HLHELP help file as it documents what the macros do.