Note: I can't be part of Colecovision; I've never even touched a Colecovision.
DocWaluigean wrote:tokumaru wrote:All numbers are signed and unsigned at the same time. That may sound confusing, but the great thing about 2's complement is that all binary operations are correct for signed and unsigned values. The only difference is how YOU interpret the results and make decisions based on them.
$FF is 255 unsigned, or -1 signed, both at the same time. If you subtract 2 from it, the result is correct either way:
$FF - $02 = $FD
Unsigned: 255 - 2 = 253
Signed: -1 - 2 = -3
The answer is correct either way. The CPU uses the carry flag to signal unsigned overflows/underflows, and the V flag to signal signed overflows/underflows. Depending on what you need the numbers for, you'll use one flag or the other (or the N flag, which's also useful after signed operations) to make decisions.
The answer on this one? Or the answer about what I wrote earlier before the questioned about signed/unsigned numbers?
So it's like a mirror-mirror style of positive and negative where...............
255 is positive [unsigned]
and 1 is negative [signed]
-
Note: we will deal with #255 as the hardware (the 6502) sees it... in binary: #11111111b
11111111 is positive [unsigned]
and 11111111 is negative [signed]
because, like tepples said, bit7 is set and so the "signed" way of using 11111111 makes that represent a negative number (-1).
You can experiment with Windows 10's Calculator to better understand signed and unsigned. Open Calculator, click the three horizontal lines in the upper left, click "Programmer's Mode". Click on the QWORD until it reads BYTE. Click on BIN. Type or click 11111111. Notice that the signed decimal value, next to DEC, reads -1. Now click BYTE again and it will goto QWORD. Then click the C to clear the calculator. Next type or click 11111111 again. Now the value next to DEC will read 255 (that's the unsigned version of #11111111b).
Windows 10's Calculator's Programmer's Mode always switches the decimal version (next to DEC) to signed when the left most bit of the value is set. Have to go... sorry.