flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > FASM sign-extends current address (why that's bad)

Author
Thread Post new topic Reply to topic
PopeInnocent



Joined: 01 Jan 2004
Posts: 18
Location: USA
PopeInnocent 09 Mar 2004, 03:24
My apologies if this has already been addressed.

The following

Code:
org 80000000h - 8

dq $
dq $    


generates the following qwords:

Code:
000000007ffffff8
ffffffff80000000    


It appears that FASM sign-extended the current address. This could lead to subtle bugs, breaks code that was written for the lower 2GB of address space when that code is assembled for the top half of memory, and it seems like it wouldn't work well for x86-64.

For instance, the construct:

Code:
db foo shr 24    


Where foo is a label, works just fine when the foo is below 2GB, but generates an error when foo is above 2GB.

Priv, do you plan on changing this feature?
Post 09 Mar 2004, 03:24
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 09 Mar 2004, 08:44
This is only because current fasm versions store "org" base address as 32-bit value. This has of course to be changed in the fasm version with 64-bit code generation. And with 32-bit code it shouldn't cause a problems, as you usually don't use 64-bit addresses in this mode.
Post 09 Mar 2004, 08:44
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.