News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

equ vs = in windows.inc

Started by Rockphorr, February 07, 2010, 11:12:36 AM

Previous topic - Next topic

Rockphorr

Hi Hutch, why do You use equ but do not '=' ???
Strike while the iron is hot - Бей утюгом, пока он горячий

UtillMasm

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.

dedndave

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

hutch--

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Rockphorr

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.
Strike while the iron is hot - Бей утюгом, пока он горячий

jj2007

> 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

MichaelW

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.
eschew obfuscation

dedndave

i think this is essentially a TEXTEQU

test1 equ <ciao>

(Warning A0C1A0: Beware of Germans speaking Italiano   :P )

Rockphorr

For short, It is just Hutch wish as autor.
But = is short then equ, and you can change it by youself.
Strike while the iron is hot - Бей утюгом, пока он горячий

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Rockphorr

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 ???
Strike while the iron is hot - Бей утюгом, пока он горячий

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

jj2007

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.

Rockphorr

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.
Strike while the iron is hot - Бей утюгом, пока он горячий

Rockphorr

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
Strike while the iron is hot - Бей утюгом, пока он горячий