flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Bug in FASM v1.69.37

Author
Thread Post new topic Reply to topic
CandyMan



Joined: 04 Sep 2009
Posts: 414
Location: film "CandyMan" directed through Bernard Rose OR Candy Shop
CandyMan 14 Feb 2012, 01:24
format MS64 COFF

section '.text' executable

virtual at 0
SortReverse db ?
end virtual

ReturnRDX:
lea rdx,[SortReverse] ;error: invalid use of symbol
ret
Post 14 Feb 2012, 01:24
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8394
Location: Kraków, Poland
Tomasz Grysztar 14 Feb 2012, 01:37
It is actually due to a bugfix - previous fasm versions incorrectly allowed "lea rdx,[0]" (this is what it is, the "virtual" thing is not an important detail here) to be assembled in such context, and it generated incorrect opcode. Because in 64-bit mode address that has no size prefix is declared to be always RIP-relative, and it is not possible to generate relocation to address absolute "0" relative to RIP. It is like writing "lea rdx,[rip-$+0]", which in turn fails for the same reason as "dd 0-$" does.
To generate a correct instruction which will load absolute value into RDX, you need to use construction like:
Code:
lea rdx,[dword SortReverse]    
Post 14 Feb 2012, 01:37
View user's profile Send private message Visit poster's website Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 138
SFeLi 18 Feb 2012, 22:27
Is something wrong with this code or with the fasm itself?
Code:
repeat 2
  virtual at 0
    db 'aa'
    db 'zz'
    ; UNCOMMENT_ME = 1
    load foo from %-1
    load bar from %-1+2
  end virtual
  baz = foo + bar
end repeat    
Post 18 Feb 2012, 22:27
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8394
Location: Kraków, Poland
Tomasz Grysztar 18 Feb 2012, 23:23
Yes, this is a correct code and should be working. I'm uploading the correction as 1.69.38.
Post 18 Feb 2012, 23:23
View user's profile Send private message Visit poster's website Reply with quote
SFeLi



Joined: 03 Nov 2004
Posts: 138
SFeLi 18 Feb 2012, 23:56
So fast! Thank you)
Post 18 Feb 2012, 23:56
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.