flat assembler
Message board for the users of flat assembler.

Index > Main > Problem with equates

Author
Thread Post new topic Reply to topic
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
the following code gives me a "value out of range" error, can anyone tell me why this is?
RNDC.NTAB equ 32
RNDC.IM1 equ 2147483563
RNDC.IMM1 equ RNDC.IM1-1
RNDC.NDIV equ 1+(RNDC.IMM1/NTAB) ;This may be the problem?
.
.
.
rndd.NDIV dd RNDC.NDIV ;<- Here is where the "value out of range" error is
Post 11 Jan 2004, 12:58
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
madmatt wrote:
Code:
RNDC.NDIV equ 1+(RNDC.IMM1/NTAB)    



it should be:

Code:
RNDC.NDIV equ 1+(RNDC.IMM1 / RNDC.NTAB)    


Only NTAB is 0, so you can't divide on it.

And better use "=" instead of "equ".

Regards
Post 11 Jan 2004, 13:07
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
Can't believe I missed that!!! Embarassed I Need to have my eyes checked! Shocked
Thanks JohnFound! Why use = instead of equ?
Post 11 Jan 2004, 13:32
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
madmatt wrote:
Why use = instead of equ?


Well, in FASM "=" is not equal to "equ" like in some other assemblers.

"equ" defines symbolic constant in very early stage of compiling. And then when you are using this symbol, FASM make simply text replacing, not value replacing. For example if you define something in the "if" condition, it will be defined even when the condition is false. Simply because definition is on preprocessing stage, but conditions are computed/executed on assembling stage.
Of course "equ" is useful in many cases, but only if you know exactly why you doing this.
The same is valid for "fix" directive. It is very similar to "equ".

On other hand, constants defined with "=" are true numerics and FASM defines/redefines them on assembling stage. (btw on this stage, the source does not exists as text, but as internal "pseudocode" data).

Regards
Post 11 Jan 2004, 13:49
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
I have another problem with 'equ'

I'd like to cut invoke function to its shorter version 4 example : inv
but i noticed that :
Code:

inv equ invoke

    
does not work.

the assembler talk to me that the instruction I want to call,it is illegal.

what should I write to be shorter.

regards,
harry

_________________
Microsoft: brings power of yesterday to computers of today.
Post 11 Jan 2004, 19:18
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3500
Location: Bulgaria
JohnFound
HarryTuttle wrote:
what should I write to be shorter.


Code:
inv fix invoke    


Regards
Post 11 Jan 2004, 20:00
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Joshua



Joined: 12 Jul 2003
Posts: 56
Location: Belgium
Joshua
inv fix invoke
Post 11 Jan 2004, 20:02
View user's profile Send private message Reply with quote
HarryTuttle



Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
Embarassed I overlooked "fix" and like in MASM tied to use equ.
BTW:J-now E-thing work well.
thank You!
h

_________________
Microsoft: brings power of yesterday to computers of today.
Post 12 Jan 2004, 06:38
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
Quote:
Well, in FASM "=" is not equal to "equ" like in some other assemblers.

"equ" defines symbolic constant in very early stage of compiling. And then when you are using this symbol, FASM make simply text replacing, not value replacing. For example if you define something in the "if" condition, it will be defined even when the condition is false. Simply because definition is on preprocessing stage, but conditions are computed/executed on assembling stage.
Of course "equ" is useful in many cases, but only if you know exactly why you doing this.
The same is valid for "fix" directive. It is very similar to "equ".

On other hand, constants defined with "=" are true numerics and FASM defines/redefines them on assembling stage. (btw on this stage, the source does not exists as text, but as internal "pseudocode" data).

Regards


Thanks Jounfound, this would be good to know for conditional assembly. which I haven't needed yet. but will most likely need in the future for assembling code for different processors.
Post 12 Jan 2004, 10:38
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.