Not quite... like tepples just said, signed and unsigned are just contexts or ways of thinking about binary values... i.e.DocWaluigean wrote:It's alright.. I'm a little confused though.unregistered wrote: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.
00000000 is unsigned
00100000 is unsigned
01000000 is signed
10000000 is signed
11000000 is signed
11010101 is signed
Is this what it means?...
00000000 binary is interpreted as 0 (unsigned decimal) and 0 (signed decimal)
10000000 binary is interpreted as 128 (unsigned decimal) or -128 (signed decimal)
Signed (there are various ways of signed) and unsigned were created in many students' Master's Theses. A day was spent by me searching through part of the UT in Austin library with Master's Theses. It was so exciting for me to just
The contexts, as tepples wisely taught, are only relevant to certain code... i.e.
Code: Select all
lda Potatoe bmi +n ;code for positive signed values here +n ;code for negative signed values here ;this bmi branches with signed decimal values -1 through -128. But, for this simple code it may be preferrable to think that this bmi branches for all binary values with bit7 set. Those are just two valid ways of thinking of this code. :)
edit: Remember to play with Windows' Calculator. If you open the Calculator app in Windows 10 and change it into "Programmer" mode as was explained on the previous page and in the quote above... it's super helpful! If you change "Programmer" mode use 8-bits (BYTE), and then click the up arrow key, you can play with RoL and RoR. Click the up arrow again to change those buttons back to Lsh and Rsh. 6502 equivalents are: rol, ror, asl, and lsr.
final edit: if you decide to use an assembler that requires CMD, like ASM6, make sure to create a batch file. My batch file is named "assemble.bat" and it contains:
Code: Select all
asm6 -L yourfilename.asm yourgamefilename.nes @echo on %date% at %time% :)
Typing out the first line each time caused me problems after a while and tokumaru helped me to start using a batch file. (Note: the second line is susposed to start with @