I find some articles with SADDR("String") in their invoke statements,
such as invoke  MessageBox,hWnd,SADDR('Game Over'),SADDR('Alert'),MB_OK
but when I apply this in my program, there is a type mismatch error occured.
SADDR looks to be very convienient when you want to display a string directly.
Can you teach me how to ?

Posted on 2005-10-25 22:39:25 by guidry
You have to use double quotes:

invoke  MessageBox,hWnd,SADDR("Game Over"),SADDR("Alert"),MB_OK

Double quotes define a string with length of 1 and above
Single quotes, like
mov eax,'ABCD'
are integers - 1 byte, 1 word, 1 doubleword or 1 quadword long.

Thus, with your first attempt at SADDR, you tried to fill 1 byte with all the specified symbols in the quote :)
Posted on 2005-10-25 23:02:18 by Ultrano
Use double quotes in SADDR() and add the followng Macros to the place between the title "WinMain Proto" and include???.lib , right?
I try this way and it works. But any more convenient way?

literal MACRO quoted_text:VARARG
       LOCAL local_text
        .data
          local_text db quoted_text,0
        .code
        EXITM <local_text>
ENDM
     
SADDR MACRO quoted_text:VARARG
       EXITM <ADDR literal(quoted_text)>
ENDM
Posted on 2005-10-26 00:52:41 by guidry
I use:

T macro Text:VARARG
        local szText
        .data
        szText byte Text, 0
        .code
        exitm <offset szText>       
endm



Place the macro wherever you want, provided that it is defined before being used. We usually place most/all of our macros in a "macros.inc" file. And then we include this macros.inc near the "includelib" statements:

include macros.inc
...
includelib kernel32.lib
...
Posted on 2005-10-26 01:14:50 by Ultrano
guidry,

There are later macros available than the two old ones you have quoted from the masm32 macros.asm file.

    fn MessageBox,hWnd,"Message Text","Title Text",MB_OK

    ; or

    cmp rv(MessageBox,hWnd,"Message Text","Title Text",MB_YESNO), IDYES
    je lbl1
    etc ....


Regards,

hutch at movsd dot com
Posted on 2005-10-26 04:52:19 by hutch--

You have to use double quotes

absolutely not true, for C yes but for MASM not.
I use:
Code:
T macro Text:VARARG
        local szText
        .data
        szText byte Text, 0
        .code
        exitm <offset szText>       
endm

me too  ;)

I try this way and it works.

you've answered your problem, you have to have the macro defined somewhere to use it.
the more convenient way should be supported by MASM, but it's not.
Posted on 2005-10-26 12:03:52 by drizz
include \masm32\macros\macros.asm
Posted on 2005-10-27 14:01:15 by Greg