Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improper warning on inversion operator #26

Open
Vov4ick opened this issue Dec 4, 2020 · 2 comments
Open

Improper warning on inversion operator #26

Vov4ick opened this issue Dec 4, 2020 · 2 comments

Comments

@Vov4ick
Copy link
Contributor

Vov4ick commented Dec 4, 2020

When immediate instruction (ldi, andi, etc) has second operand with inversion operator and MSB of its expression is set, for example, ~(128), this produces constant out of range warning. Result of assembly is correct.

@Ro5bert
Copy link
Owner

Ro5bert commented Dec 4, 2020

I'll look into this more later, but I'm guessing it's because the internal representation of integers is more than 8bits, so when 128 gets inverted, the result isn't 127. For now you could silence the warning by doing low(~128).

@Ro5bert
Copy link
Owner

Ro5bert commented Jan 4, 2021

There's a comment related to this in the usage file:

The expression (~0x80) is a Bitwise Not operation. This operator returns the input expression with all its bits inverted. If 0x80 represents -128, then 0x7f, or +127 should be ok. If this is considered as a 32-bit expression (AVRA internal representation), then it appears to be more like oxffffffff-0x80 or 0xffffffff^0x80. The result would then be 0xffffff7f. The assembler would then have to be told or it would have to decide, based on context, how much significance to assign to the higher bits. I have also encountered such conditions with various assemblers, including AVRA. To make sure the assembler does what I really want, I use a construct like 0xff-0x80 or 0xff^0x80. This way the bit significance cannot extend beyond bit-7 and there cannot be any misunderstanding.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants