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
now this works when Is use this
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
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
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
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.
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?
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?
Yes It would work when I set it up like this
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?
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?
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.
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.
Oh I see thanks for clearing up that for me. :)