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 ?
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 ?
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 :)
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 :)
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
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
I use:
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:
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
...
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
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
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
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.
include \masm32\macros\macros.asm