Re: [cc65] bitwise not broken in ca65?

From: Ullrich von Bassewitz <>
Date: 2011-12-24 14:41:01

On Sat, Dec 24, 2011 at 07:51:21PM +0800, Simon Scott wrote:
> When I try to build opencbm, it throws an error:
> tdchange.a65(151): Error: Range error (-9 not in [0..255])
> tdchange.a65(169): Error: Range error (-5 not in [0..255])
> so, it looks like ca65 is resolving ~$08 as -9, and ~$04 and -5 (ie, 2's
> complement) rather than an actual bitwise NOT.

This is caused by an error in older ca65 versions which has been fixed
recently. So old code exploiting the behaviour does no longer work.

ca65 doesn't silently truncate to a byte or word. This may be annoying in some
situations, but helpful in others. So what happens is

        NOT $00000008 => $FFFFFFF7

which is larger than a byte and gives a range error. Just force it to be byte
wide and the error will go away:

        and     #<~drDriveLED

I wish all readers of the list a merry christmas! Thanks for all your
contributions and the helpful discussion.



Ullrich von Bassewitz                        
To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sat Dec 24 14:41:12 2011

This archive was generated by hypermail 2.1.8 : 2011-12-24 14:41:15 CET