flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Compiler Internals > Strangeness with xor operator in constants expression

Author
Thread Post new topic Reply to topic
bazizmix



Joined: 15 Jan 2016
Posts: 31

Strangeness with xor operator in constants expression

flat assembler version 1.72
Simple text:

Code:

ZZZ equ 1
mov eax,-1 xor ZZZ
mov eax,ZZZ xor -1


and produced code:

Code:

B8 00 00 00 00 | mov eax,0         <-- wrong
B8 FE FF FF FF | mov eax,FFFFFFFE  <-- right


But!!!

Code:

ZZZ equ 2
mov eax,-1 xor ZZZ
mov eax,ZZZ xor -1


all OK:

Code:

B8 FD FF FF F | mov eax,FFFFFFFD
B8 FD FF FF F | mov eax,FFFFFFFD 

Post 04 Feb 2018, 12:30
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 15638
Location: Thasus

Unary minus has a lower precedence than xor. You can put brackets around the leading minus to force what you need.

Code:
mov eax,(-1xor ZZZ



Last edited by revolution on 04 Feb 2018, 13:48; edited 1 time in total
Post 04 Feb 2018, 13:03
View user's profile Send private message Visit poster's website Reply with quote
bazizmix



Joined: 15 Jan 2016
Posts: 31

Thanks, revolution!
Post 04 Feb 2018, 13:27
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


Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2018, Tomasz Grysztar.
Powered by rwasa.