flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > Bug ? (value out of range)

Author
Thread Post new topic Reply to topic
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

in both cases "use32"

in first case: value out of range, does not compile ... 100% ok.

in second case: does compile without problem too. Shocked (???)



Image

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 05 Nov 2011, 22:50
View user's profile Send private message Send e-mail Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7724
Location: Kraków, Poland
Tomasz Grysztar
This is one of the side-effects of fasm's flaw that it calculates on 64-bit numbers instead of 65-bit, as it really should. 18446744073709551615 is the same as 0FFFFFFFFFFFFFFFFh, which fasm interpretes as -1. And -1 does fit into double word (as 0FFFFFFFFh). See the link for all the details, including some background on TASM, too.
Post 05 Nov 2011, 22:58
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji


"fasm calculates on 64-bit numbers instead of 65-bit"

I think this side-effect is more important than simply trigger a misinterpretation of -1.
Fasm is a fantastic compiler, i think it would deserve a fix for this (old) problem.
Just my opinion.

mov ebx, $FFFFFFFFFFFFFFFF + 10 ;does compile

mov ebx, $FFFFFFFF + 10 ;does not compile

That said, I looked closely at your code about real numbers, nice work !

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 05 Nov 2011, 23:38
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: 17279
Location: In your JS exploiting you and your system
revolution
ouadji: Currently in fasm:

- addition and subtraction will never overflow.

- Multiplication can overflow.
Post 05 Nov 2011, 23:43
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

addition (and subtraction) will never overflow

in this case, why this:

mov eax, 0xFFFFFFFF + 1 ;---> value out of range

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 05 Nov 2011, 23:48
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: 17279
Location: In your JS exploiting you and your system
revolution
ouadji wrote:

addition (and subtraction) will never overflow

in this case, why this:

mov eax, 0xFFFFFFFF + 1 ;---> value out of range
It is not the addition that is overflowing. It is when you try to force a 33 bit number into a 32 bit register.
Post 05 Nov 2011, 23:52
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17279
Location: In your JS exploiting you and your system
revolution
BTW: In case you are curious here is the original topic about 65 bit processing. A small example of it in action.

http://board.flatassembler.net/topic.php?p=27758#27758
Post 05 Nov 2011, 23:54
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji

Quote:
It is not the addition that is overflowing.
It is when you try to force a 33 bit number into a 32 bit register.
Code:
mov ebx, $1'FFFF'FFFF ;33bits ==> "value out of range"    

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 06 Nov 2011, 00:01
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: 17279
Location: In your JS exploiting you and your system
revolution
To test overflow use something like this:
Code:
x=1 shl 63 + 1 shl 63     ;does not overflow
y=0 - 1 shl 63 - 1 shl 63 ;does not overflow
z=1 shl 63 * 1 shl 63     ;die    
Post 06 Nov 2011, 00:06
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-2020, Tomasz Grysztar.

Powered by rwasa.