;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func1 proc Param1:DWORD

option PROLOGUE:none
option EPILOGUE:none

dwParam TEXTEQU <[esp + sizeof DWORD]>

mov eax, dwParam

ret sizeof DWORD

option PROLOGUE:PROLOGUEDEF
option EPILOGUE:EPILOGUEDEF

Func1 endp

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func2 proc

LOCAL dwParam:DWORD

mov eax, dwParam

ret

Func2 endp

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



When i try to assemble this code, MASM reports "error A2008: syntax error : ["
Because of dwParam in Func2 is previously defined in Func2 as ""
So, my question is: "Is there any posibility to undefine previously defined symbol?"
Please any idea.
Posted on 2001-10-03 09:15:14 by Four-F
if u'll change thr order of the procs and it will work fine



Func2 proc

LOCAL dwParam:DWORD

mov eax, dwParam

ret

Func2 endp

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func1 proc Param1:DWORD

option PROLOGUE:none
option EPILOGUE:none

dwParam TEXTEQU <[esp + sizeof DWORD]>

mov eax, dwParam

ret sizeof DWORD

option PROLOGUE:PROLOGUEDEF
option EPILOGUE:EPILOGUEDEF

Func1 endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Posted on 2001-10-03 09:42:50 by NEMO
Try:


blah TEXTEQU <mov eax, 1>
blah TEXTEQU <@blah>


You could probably make an UNDEF macro that would do it automatically!

I've not tested it, other than looking at the full expanded listings.

Mirno
Posted on 2001-10-03 10:12:29 by Mirno
Thanks, but...

NEMO. It's too simple, He-he!

I've posted code only to show, where it (undefine) would be useful.

Mirno. Sorry, but didn't understand blah TEXTEQU <@blah>.
@ - is it only symbol or what?

My goal is REALLY UNDEFINE (Well, remove from internal MASM structures) symbol that i previously defined.
It wouid be IMHO very useful in many cases.
But MASM documentation says nothing about it. (may be i missed something).
Posted on 2001-10-03 10:50:06 by Four-F
In the masm documentation is says specifically that EQUs cannot be redfined, TEXTEQUs can be though.

The code I gave above causes all instances of the text "blah" to be replaced with "blah"! The compiler will then carry on with the next pass, and all is right with the world.

Athough strictly not undefined, it does leave the code acting as expected.

Mirno
Posted on 2001-10-03 11:47:28 by Mirno
Four-F,

in your example this may work:



KONST textequ <[ESP]>

mov eax,KONST

KONST equ nothing

xxxx proc

local KONST:dword

mov eax,KONST

xxxx endp




But since this is fairly documented it may depend on MASM versions.

japheth
Posted on 2001-10-04 04:02:01 by japheth
I'm not shure but I think

equ defines hard wired
= defines and can be redefined
Posted on 2001-10-04 04:11:11 by beaster
Oh, thank you, japheth!
This is exactly what i wanted :)

BTW, in my experiments i've tried undefine similar way, but i used TEXTEQU:

KONST textequ <>
mov eax,KONST
KONST textequ nothing

Thanks for the tip to use EQU :alright:
Posted on 2001-10-04 08:45:40 by Four-F
Four-F,
yesterday I suddenly doubted if my suggestion above is really a solution. I have checked the listing file and must say now it is not.
With

KONST equ nothing

you just redefine a text macro. Since "nothing" isnt a reserved word in MASM, a following definition of

local KONST:dword

then defines a variable "nothing".

To undefine there remains "purge", but this doesn't work with text macros as far as I know.

japheth
Posted on 2001-10-05 02:03:33 by japheth
I've confused about NOTHING. :confused:

It's not reserved

This what MASM docs says:
"...they should not be defined to be text macros or text macro functions.
If they are, they will not be recognized in their special contexts.
The assembler does not give a warning if such a redefinition occurs."


Damn! :mad: Looks like undefinition is impossible.
Posted on 2001-10-05 06:07:53 by Four-F
What actually happens is that the text is replaced with the new text, ie. "KONST" is replaced with "nothing".

So:


dwParam EQU nothing

Func1 proc dwParam:DWORD
mov eax, dwParam
ret
Func1 endp

--------- Becomes ---------


Func1 proc nothing:DWORD
mov eax, nothing
ret
Func1 endp

After the inbuilt pre-parser is done with your code.
This means that there could be re-definition problems (if you ever call a variable "nothing").

If you change the EQUATE to the same as the lable, that would techincally work, however that causes nesting problems for the pre-parser, and it will not compile.

If you use a TEXTEQU and state that it is explicitly text, and therefore cannot be re-evaluated, then it will be fine.
To do this you need to do the following:
name TEXTEQU <@name>

eg.
blah TEXTEQU <@blah>

Note, the @ symbol specifies it as explicit text, and not an expression, which would be re-evaluated in a second pass (and hence nest).

Mirno
Posted on 2001-10-05 06:52:25 by Mirno
does it mean we can not undefine the symbol in MASM?
Posted on 2001-10-09 11:42:59 by doby