Hello, I have got the macro to work quite nicely, but not the way I want it to. I want to learn how to pass a parameter to the macro and from what I can figure out all you have to do is type the variable name after the macro name when you call it right? Here is what I have so far to just print a string to the console
TITLE MASM AM9						(AM9.asm)

; Description:
;
; Revision date:

INCLUDE Irvine32.inc

;macro stuff

mWriteString MACRO text
LOCAL string
.data
string db text
.code
push edx
mov edx,OFFSET string
call WriteString
pop edx

ENDM

.data
myStr db "Test1",0

.code
main PROC
call Clrscr 
mWriteString myStr
call Crlf

exit
main ENDP

END main


now this works when Is use this
main PROC
call Clrscr 
mWriteString "Some String"
call Crlf

exit
main ENDP

but then fails when I try to pass the parameter from the .data section above the main.
The error it gives is this
1>AM9.asm(30): error A2071: initializer magnitude too large for specified size
does that mean I cant pass the string variable name to it?
Thanks for any help
Posted on 2011-11-15 09:24:50 by lordgus
Shouldn't the string be zero-terminated?


mWriteString MACRO text
LOCAL string
.data
string db text,0
.code
push edx
mov edx,OFFSET string
call WriteString
pop edx

ENDM
Posted on 2011-11-15 11:16:57 by JimmyClif
Yes I done that too and it still gives me an error I was wondering if that was it but the error seams to be in the main proc and not the marco.
Posted on 2011-11-15 11:36:48 by lordgus
Hold on.. I just re-read your question.

You say : It works as a Macro with a string attached like mWriteString "test" but not when you pass a declared string from data to your macro?

Posted on 2011-11-15 15:45:09 by JimmyClif
Yes It would work when I set it up like this
TITLE MASM AM9						(AM9.asm)

; Description:
;
; Revision date:

INCLUDE Irvine32.inc

;macro stuff

mWriteString MACRO text
LOCAL string
.data
string db text
.code
push edx
mov edx,OFFSET string
call WriteString
pop edx

ENDM

.data
myStr db "Test1",0

.code
main PROC
call Clrscr 
mWriteString "Some String"
call Crlf

exit
main ENDP

Kinda weird I don't know why that even working. It will print out Some String

I am think I am passing something wrong here or do I have the macro mixed up with a procedure?

Posted on 2011-11-16 08:37:24 by lordgus
Well, you cannot pass a declared string to your macro as your macro is setup to declare it to be a new string.

If the macro works then all is well, not?

To pass a declared string you would just call WriteString with the offset of your string and not use your macro.

Apples and Oranges.
Posted on 2011-11-16 12:39:33 by JimmyClif
Oh I see thanks for clearing up that for me. :)
Posted on 2011-11-16 12:59:50 by lordgus