ICC issue with const and division

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

Post Reply
Jerry Messina
Swordfish Developer
Posts: 1473
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

ICC issue with const and division

Post by Jerry Messina » Mon May 01, 2023 1:03 pm

There's a code generation issue involving const values and division, and crops up if you have something like:

Code: Select all

w1 = const / w2
where w1 and w2 are words and the const value is > 65535.
Currently the compiler truncates the const value to a word and does a div16x16 operation, so the result will not be correct.

This will be fixed in the next update, but a simple workaround is to cast the operation to a longword...

Code: Select all

w1 = longword(const/w2)
This won't fix any overflow issues you might have since the operation isn't really valid for all values anyway, but for those values where it is you'll now get the correct result.

Post Reply