flat assembler
Message board for the users of flat assembler.

 Index > Main > Problem with equates
Author

Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
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
11 Jan 2004, 12:58
JohnFound

Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound
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
11 Jan 2004, 13:07

Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
Can't believe I missed that!!! I Need to have my eyes checked!
Thanks JohnFound! Why use = instead of equ?
11 Jan 2004, 13:32
JohnFound

Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound
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
11 Jan 2004, 13:49
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.
11 Jan 2004, 19:18
JohnFound

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

Code:
`inv fix invoke    `

Regards
11 Jan 2004, 20:00
Joshua

Joined: 12 Jul 2003
Posts: 56
Location: Belgium
Joshua
inv fix invoke
11 Jan 2004, 20:02
HarryTuttle

Joined: 26 Sep 2003
Posts: 211
Location: Poland
HarryTuttle
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.
12 Jan 2004, 06:38

Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
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.
12 Jan 2004, 10:38
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainTutorials and ExamplesDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsOS ConstructionIDE DevelopmentProjects and IdeasNon-x86 architecturesHigh Level LanguagesProgramming Language DesignCompiler Internals Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum