The MASM Forum Archive 2004 to 2012

Project Support Forums => MASM32 => WINDOWS.INC Project => Topic started by: Rockphorr on February 07, 2010, 11:12:36 AM

Title: equ vs = in windows.inc
Post by: Rockphorr on February 07, 2010, 11:12:36 AM
Hi Hutch, why do You use equ but do not '=' ???
Title: Re: equ vs = in windows.inc
Post by: UtillMasm on February 07, 2010, 11:36:50 AM
sorry, i'm fake hutch:=
   Assigns the numeric value of expression to name.
     name = expression
   Remarks
     The symbol can be redefined later.

equ
   The first directive assigns numeric value of expression to name.
     name equ expression
     name equ <text>
   Remarks
     The name cannot be redefined later.
     The second directive assigns specified text to name. The name can be assigned a different text later. See TEXTEQU.
so, they must be different.
Title: Re: equ vs = in windows.inc
Post by: dedndave on February 07, 2010, 12:13:05 PM
EQU cannot be re-assigned (except TEXTEQU, which can be)
= can be re-assigned

blah = 1
        mov     eax,blah    ;eax = 1
blah = 9
        mov     eax,blah    ;eax = 9

if you try that with EQU, i think it throws a multiple definition assembly error
by using EQU in windows.inc, it prevents programmers from accidently changing the values
Title: Re: equ vs = in windows.inc
Post by: hutch-- on February 07, 2010, 12:30:02 PM
 :bg

Yurp !
Title: Re: equ vs = in windows.inc
Post by: Rockphorr on February 07, 2010, 03:03:45 PM
Quote from: dedndave on February 07, 2010, 12:13:05 PM
EQU cannot be re-assigned (except TEXTEQU, which can be)
= can be re-assigned

blah = 1
        mov     eax,blah    ;eax = 1
blah = 9
        mov     eax,blah    ;eax = 9

if you try that with EQU, i think it throws a multiple definition assembly error
by using EQU in windows.inc, it prevents programmers from accidently changing the values

To accidently change predefined value with asm- programming is lol :) (They are well known)
To prevent a change everyone can use IFDEF/IFNDEF.
Title: Re: equ vs = in windows.inc
Post by: jj2007 on February 07, 2010, 04:22:44 PM
> EQU cannot be re-assigned
So says the manual. Try your luck:

include \masm32\include\masm32rt.inc

mac1 MACRO
test1 equ <ciao>
% echo test1
test1 equ <hello>
% echo test1
ENDM

.code
start:
mac1
test2 equ <ciao #2>
% echo test2
test2 equ <hello #2>
% echo test2
getkey
exit
end start
Title: Re: equ vs = in windows.inc
Post by: MichaelW on February 07, 2010, 04:37:22 PM
The actual statement (from the Version 6.0 manual, emphasis added):
Quote
The difference between EQU and = is that integers defined with the = directive can be changed in your source code, but those defined with EQU cannot.
Title: Re: equ vs = in windows.inc
Post by: dedndave on February 07, 2010, 04:54:06 PM
i think this is essentially a TEXTEQU

test1 equ <ciao>

(Warning A0C1A0: Beware of Germans speaking Italiano   :P )
Title: Re: equ vs = in windows.inc
Post by: Rockphorr on February 08, 2010, 08:00:48 PM
For short, It is just Hutch wish as autor.
But = is short then equ, and you can change it by youself.
Title: Re: equ vs = in windows.inc
Post by: hutch-- on February 08, 2010, 08:10:23 PM
Rockphorr,

No, its a safety design issue, equ makes the equate reliable where = is not for equates. They are different so that you can write different code that does different things.
Title: Re: equ vs = in windows.inc
Post by: Rockphorr on February 09, 2010, 01:51:18 PM
Quote from: hutch-- on February 08, 2010, 08:10:23 PM
Rockphorr,

No, its a safety design issue, equ makes the equate reliable where = is not for equates. They are different so that you can write different code that does different things.

Give me please a samle to show it.
I think that these constants are use to mov to reg and push to stack.
For this purporse the safety is not important.
Why do everyone change it ???
Title: Re: equ vs = in windows.inc
Post by: hutch-- on February 09, 2010, 02:25:42 PM
Rockphorr,

Just check the MASM reference material, an equate is a non-changing value and is properly written using the EQU notation so that it cannot be changed. MASM has both notations so you can do different things, equates are fixed where assigned values can be changed, just pick the capacity you need.
Title: Re: equ vs = in windows.inc
Post by: jj2007 on February 09, 2010, 02:36:57 PM
Quote from: Rockphorr on February 09, 2010, 01:51:18 PM
Why do everyone change it ???

Imagine you have two different include files, windows.inc and MyExotic.inc. They both define SOME_EXOTIC_VALUE = 123h
For Masm 11.0, Hutch corrects a mistake, and now SOME_EXOTIC_VALUE = 124h. Since there are many exotic values to be corrected, he will not inform you about each and every one.

And one day, your 10,000 lines code starts behaving strangely. Can you imagine how difficult it will be to find out why? With SOME_EXOTIC_VALUE EQU 123h, you would just get an error message, and comment the one in MyExotic.inc to fix the problem.
Title: Re: equ vs = in windows.inc
Post by: Rockphorr on February 10, 2010, 06:47:53 AM
Quote from: hutch-- on February 09, 2010, 02:25:42 PM
Rockphorr,

Just check the MASM reference material, an equate is a non-changing value and is properly written using the EQU notation so that it cannot be changed. MASM has both notations so you can do different things, equates are fixed where assigned values can be changed, just pick the capacity you need.

Ok. Are equs in windows.inc required ? I think you do it to make more simply a learning masm.

Beginners some time do something that we can not imagine.
Title: Re: equ vs = in windows.inc
Post by: Rockphorr on February 10, 2010, 06:57:04 AM
Quote from: jj2007 on February 09, 2010, 02:36:57 PM
Quote from: Rockphorr on February 09, 2010, 01:51:18 PM
Why do everyone change it ???

Imagine you have two different include files, windows.inc and MyExotic.inc. They both define SOME_EXOTIC_VALUE = 123h


I always do not define double definitions. Every defenition is in windows.inc XOR in MyExotic.inc