flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Bug compiling 1.0e-317 floating-point number

Author
Thread Post new topic Reply to topic
ejamesr



Joined: 04 Feb 2011
Posts: 52
Location: Provo, Utah, USA
ejamesr 22 May 2014, 15:30
There is a FASM bug (v 1.71.20) when compiling the number 1.0e-317. In the example below, FASM compiles the number as 4.294967e-308. These are tiny denormal numbers, so the values aren't exactly what the human eye would expect, but this is clearly a bug.

The code below loads each number into the FPU, so that you can step through the code to see how the FPU interprets it.

Code:
format PE GUI 4.0
entry start
include 'win32w.inc'
section '.text' code readable executable
start:
        ; Loop through values...
        mov     ecx, Nums.len
        mov     esi, Nums
@@:
        fld     qword [esi]     ; Load number to look at
        fstp    st0             ; Pop off FPU stack
        add     esi, 8          ; Next Num...
        dec     ecx
        jnz     @b
        invoke  ExitProcess, -1
section '.data' data readable writeable
align 8
label Nums qword
        dq 1.0e-318
        dq 1.0e-317             ; FASM thinks this is 4.294967e-308!!!!
        dq 1.0e-316
        dq 1.0e-315
.len = ($-Nums)/8
section '.idata' import data readable writeable
library kernel32,'KERNEL32.DLL',\
        user32,'USER32.DLL'
include 'api\kernel32.inc'
include 'api\user32.inc'    


I've suspected this corruption before in previous versions when compiling floating-point numbers, and now I've finally nailed it with some easy-to-reproduce code.

Please fix this!!

ejamesr
Post 22 May 2014, 15:30
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20413
Location: In your JS exploiting you and your system
revolution 22 May 2014, 15:41
I have stickied.
Post 22 May 2014, 15:41
View user's profile Send private message Visit poster's website Reply with quote
ejamesr



Joined: 04 Feb 2011
Posts: 52
Location: Provo, Utah, USA
ejamesr 22 May 2014, 15:46
Thanks!
Post 22 May 2014, 15:46
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 27 May 2014, 10:15
I believe I have it fixed in 1.71.21.
Post 27 May 2014, 10:15
View user's profile Send private message Visit poster's website Reply with quote
ejamesr



Joined: 04 Feb 2011
Posts: 52
Location: Provo, Utah, USA
ejamesr 27 May 2014, 16:22
Awesome, thank you!! I just tested it, and it works fine. Razz

Thanks for jumping on this so quickly!!
Post 27 May 2014, 16:22
View user's profile Send private message Send e-mail 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.