The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Chambao on June 25, 2005, 03:21:29 PM

Title: macro help
Post by: Chambao on June 25, 2005, 03:21:29 PM
hello everyone
i have this macro whichs declares some texts and aligns it.

STRING MACRO args:VARARG
LOCAL name
.data
name db args,0
align 4
exitm <name>
ENDM

.data
szSomeText = STRING ("Global Text")
szSomeChrs = STRING (39h,17h,33h,24h,74h,4Fh,09h,4Ch,9Eh,88h,90h ...)


I got the following error on szSomeChrs :(
error A2070: invalid instruction operands
Title: Re: macro help
Post by: roticv on June 25, 2005, 03:29:26 PM
shouldn't it be


STRING MACRO args:VARARG
LOCAL name
.data
align 4
name db args,0
exitm <name>
ENDM
Title: Re: macro help
Post by: Chambao on June 25, 2005, 03:31:35 PM
same problem :)
Title: Re: macro help
Post by: Mark Jones on June 25, 2005, 04:22:52 PM
Do any of your hex values start with A-F? If so, make sure they start with a 0 - i.e., 0A2h, 0F0h, etc.
Title: Re: macro help
Post by: Chambao on June 25, 2005, 11:46:23 PM
none of my hex values start with A-F
but i have replace "=" with "textequ" and it works now
Title: Re: macro help
Post by: gfalen on June 26, 2005, 01:51:25 AM
.CODE  <***
exitm <name>
ENDM



Title: Re: macro help
Post by: Chambao on June 26, 2005, 07:36:44 PM
if i put .code i get an error as well -> "invalid instruction operands"
textequ does the trick :D
Title: Re: macro help
Post by: AeroASM on June 26, 2005, 09:11:47 PM
The .code does not fix the error - it is just needed.

You should use equ instead of textequ.
Title: Re: macro help
Post by: MichaelW on June 26, 2005, 10:22:57 PM
Chambao,

The .code and .data directives end the current segment and start a new one. The .code directive would be necessary if the macro were expanded in the code segment. Using the macro to define strings in the data segment provides no real benefit because it requires at least as much typing as would be necessary to define the strings by the normal method for static data. Using the macro to define strings in the code segment would allow you to define the strings in the source at the location where they will be used. See the MASM32 STRING macro (\masm32\macros\MACROS.ASM).
Title: Re: macro help
Post by: Chambao on June 28, 2005, 04:49:59 AM
I am not expanding the macro in the code segment, i just want to use them in the data segment.
the only benefit that I am looking for is to be able to align the defined string, so I wont have to type "align 4" for each defined string.
that way all defined string will be just in one part of my code.
Title: Re: macro help
Post by: Chambao on June 28, 2005, 04:51:32 AM
Quote from: AeroASM on June 26, 2005, 09:11:47 PM
The .code does not fix the error - it is just needed.

You should use equ instead of textequ.

equ gives me error as well --> "use of register assumed to ERROR"
textequ does the trick :o