Re: [cc65] bitwise not broken in ca65?

From: Ullrich von Bassewitz <>
Date: 2011-12-31 15:13:34

On Sat, Dec 31, 2011 at 02:28:22PM +0100, Spiro Trikaliotis wrote:
> Just an idea: If the result should be 8 bit only, couldn't the NOT
> operator just invert the lower 8 bits? As far as I see, both your
> problem as well as mine would be solved then.

Won't work. Here is an example:

        Val     = $AA55
        Mask    = $00FF

        .byte   (Val & ~Mask) >> 8

Result is 8 bit wide, but wrong if the NOT operator just works on the low

> Despite this: Would you accept a patch that tries to introduce this
> behaviour (making the creation of a viable patch my problem again, not
> yours?)

If you come up with a solution that works with aritrary expressions and
doesn't mess up the existing code then yes, I would be glad about such a
patch. But I doubt that such a solution is possible given that expressions can
be quite complex and could involve macros or pseudo functions.

However, I had another idea: Currently expressions are evaluated and later
matched against the result size and signedness. The problem here is that
immediate operands are expected to be unsigned, so the range is checked to be
within [0..255]. This fails for negative numbers or when using bitwise not,
since the latter is executed at least with 32 bits. If I would introduce a
hybrid (can either be signed or unsigned) with a range of [-128..255] (or
[-32768..65535] for words) the assembler and linker could still detect most
errors but avoid having to specify the "low byte" operator each time, negative
numbers or bitwise not is used.

I'm not sure how much work it is, since this new type has to be passed to the
linker via the object file.

I wish anybody on the list a happy new year! I've had some time for cc65 over
the holidays and introduced arbitrary alignments (not just powers of two) and
integrated Chris Bairds Mitsubishi 740 patches for da65 - just in case someone
needs something to play with:-)



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 31 15:13:42 2011

This archive was generated by hypermail 2.1.8 : 2011-12-31 15:13:45 CET