flat assembler
Message board for the users of flat assembler.

 Index > Main > Problem with \$-operator
Author
16bitPM

Joined: 08 Jul 2011
Posts: 30
16bitPM 08 Jul 2011, 12:57
Hello all,

I'm totally new on this forum so please forgive me if I'm asking stupid questions
I'm fairly new with FASM but I'm quite experienced with x86 assembly.

To learn the syntax of FASM a bit, I decided to convert the code from LATTICE.ASM (256 byte demo). The problem is as follows:

the code uses inline offset arithmetic using the \$⁻operator.
However, FASM appears to calculate the offsets differently.
I used debugx to disassemble the code and I got the following result, in this example for the following code:

Code:
ROTATE fild    word [si-EYE+ZMOVE]
fidiv  word [si-EYE+SCALE]

ORIGINAL object code:

Code:
0863:015F DF 44 C6 FILD WORD PTR [SI-3A]
0863:0162 DE 41 C1 FIDIV WORD PTR [SI-3F]

FASM object code:

Code:
0863:015F DF 44 FC FILD WORD PTR [SI-04]
0863:0162 DE 41 A8 FIDIV WORD PTR [SI-58]

I was wondering if this behaviour is known and what to do about it.

PS: I included the full source code of both versions.

08 Jul 2011, 12:57
revolution
When all else fails, read the source

Joined: 24 Aug 2004
Posts: 19098
revolution 08 Jul 2011, 13:09
The problem is the operation of equ. In fasm equ is a textural replacement not a numeric computation. Use equals (=) instead.
Code:
EPSILON        =       \$-4
;...
ZMOVE   =     \$-2
;...
EYE =       \$-2
08 Jul 2011, 13:09
16bitPM

Joined: 08 Jul 2011
Posts: 30
16bitPM 08 Jul 2011, 21:14
revolution wrote:
The problem is the operation of equ. In fasm equ is a textural replacement not a numeric computation. Use equals (=) instead.
Code:
EPSILON =       \$-4
;...
ZMOVE   =     \$-2
;...
EYE =       \$-2

Thank you! That totally worked!
08 Jul 2011, 21:14
 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