Closed 100thCoin closed 4 months ago
This seems correct per the answers to https://stackoverflow.com/questions/15674560/6502-relative-address-mode-wrapping, and the referenced visual 6502 behavior.
I don't think this is the "correct" way of doing that
What exactly do you mean?
It's being implicitly widened by the addition, then truncated. I believe if the operands were truncated to u16 first then the addition would also overflow (unchecked
is still the default...), producing the same result. But the language's type inference fights you every step of the way.
I believe if the operands were truncated to u16 first then the addition would also overflow
The result of ushort + ushort
in C# is int
, and cannot carry, overflow, wrap, or anything like that, so I'm not sure what you're proposing.
This casts the value being printed to a ushort in order to prevent it from reading $10000 or $FFFFFFFF
This fixes #3963
Before:
After: