flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > FASM accept negative immediates in ENTER and INT

Goto page Previous  1, 2
Author
Thread Post new topic Reply to topic
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 26 Jan 2010, 10:34
bitRAKE wrote:
If the processor operates with an unsigned number then negative numbers are incorrect. Since FASM correctly errors in some cases and has the precision to detect a number out of bounds, I assume the implementation is just incomplete rather than having this behavior as a feature. Hiding coding errors is never desirable.

That's right - there isn't much to discuss here.
Fix will be coming soon.
Post 26 Jan 2010, 10:34
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: 20299
Location: In your JS exploiting you and your system
revolution 26 Feb 2010, 10:08
Code:
bt ax,-1
bt eax,-1    
Should fasm allow negative values for register operands?
Post 26 Feb 2010, 10:08
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 26 Feb 2010, 17:19
It is documented the same way for btc, btr, bts, shr, shl, shld and shrd, it takes the modulo bits_of_dest of the immediate.

As for legitimate uses of this could be "counting from the left" immediate, so if you always want to take the bit just before the sign bit, you use -2 and then you don't care of the dest register your macro will receive because the immediate will always pick the correct.

For the others you can think of them as "keep the last/first n bits" again with independence of the destination size.

I've just woke up so I hope I didn't say complete nonsense Laughing
Post 26 Feb 2010, 17:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 26 Feb 2010, 22:45
Code:
 pshufd  xmm0,xmm1,-1    
Question
Post 26 Feb 2010, 22:45
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 26 Feb 2010, 23:48
Since imm8 there is working as some sort of bit set, I think it is right to accept negative values.

The only problem I see however, is that since fasm can't distinguish between 64-bit negatives and real negatives, there is some kind of odd thing in that fasm accepts all ones or all zeros but not any other combination in the upper 48-bits. I think that the imm8 in pshufd xmm0, xmm1, $FFFF'FFFF'FFFF'FFxx may have to be considered out of range because the Fs are not acting as selectors of any muxer. On the other hand, in $0000'0000'0000'00xx the 0s are not handling any muxer neither but it is a correct representation of the $xx number and for that reason the all Fs version may be a correct representation of a negative imm8 as well...
Post 26 Feb 2010, 23:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 26 Feb 2010, 23:59
LocoDelAssembly wrote:
... upper 48-bits.
I presume you mean 56-bits?

For the BT case I think that negatives are okay. But for the PSHUFD (and similar) there is no notion of the imm8 having a sign. Indeed is it not even an integer value, it is a bitmap selection. To use negative numbers is a strange way to define a bitmap constant.
Post 26 Feb 2010, 23:59
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:  
Goto page Previous  1, 2

< 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.