NOT making sense

Basic and Machine Language

Moderator: Moderators

Post Reply
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

NOT making sense

Post by Jeff-20 »

I feel like it has been discussed here, or I read about it in a book somewhere... But can anyone explain how the boolean operator NOT works on the VIC?

My mind tells me:
NOT 0 = 1
NOT 1 = 0

But my VIC tells me:
NOT 0 = -1
NOT 1 = -2

I know CBM BASIC returns -1 as TRUE and 0 as FALSE, but it doesn't make clear to me why -2 is here... like on a BIT level.
High Scores, Links, and Jeff's Basic Games page.
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: NOT making sense

Post by Mike »

NOT 1 = NOT(%0000 0000 0000 0001) = %1111 1111 1111 1110 = -2 in two's-complement with 16-bit integers.
User avatar
Jeff-20
Denial Founder
Posts: 5759
Joined: Wed Dec 31, 1969 6:00 pm

Re: NOT making sense

Post by Jeff-20 »

Mike wrote: Tue Sep 29, 2020 1:28 am NOT 1 = NOT(%0000 0000 0000 0001) = %1111 1111 1111 1110 = -2 in two's-complement with 16-bit integers.
Thanks, Mike! I finally get it now.
High Scores, Links, and Jeff's Basic Games page.
Post Reply