flat assembler
Message board for the users of flat assembler.

Index > Main > Problem with $-operator

Author
Thread Post new topic Reply to topic
16bitPM



Joined: 08 Jul 2011
Posts: 28
16bitPM
Hello all,

I'm totally new on this forum so please forgive me if I'm asking stupid questions Wink
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.

Thanks for you reply!
PS: I included the full source code of both versions.


Description: My conversion to FASM syntax
Download
Filename: LATTICE3.ASM
Filesize: 2.34 KB
Downloaded: 109 Time(s)

Description: Original Code , suspected TASM
Download
Filename: LATTICE.ASM
Filesize: 2.19 KB
Downloaded: 122 Time(s)

Post 08 Jul 2011, 12:57
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17280
Location: In your JS exploiting you and your system
revolution
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    
Post 08 Jul 2011, 13:09
View user's profile Send private message Visit poster's website Reply with quote
16bitPM



Joined: 08 Jul 2011
Posts: 28
16bitPM
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! Smile
Post 08 Jul 2011, 21:14
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. Also on YouTube, Twitter.

Website powered by rwasa.