This is work in progress... This tutorial is planned to start in 2020
Despite it's failure in the market the TMS9900 is a fascinating chip, it has virtually no registers, instead using 'Workspaces'... banks of 32 bytes that make the 16 regsiters (like a zeropage)... it also has no stack!
When a function is called, one register is used as a 'Link pointer' - pointing to the return address... if we need new registers for our subroutine, we allocate another 'workspace' giving us a new set of registers - when we're done we restore the original workspace.
Systems covered in these tutorials
What is the TMS9900 and what are 8 'bits' You can skip this if you know about binary and Hex (This is a copy of the same section in the Z80 tutorial)
The TMS9900 is an 16-Bit processor with a 15 bit Address bus!
What's 8 bit... well, one 'Bit' can be 1 or 0
four bits make a Nibble (0-15)
two nibbles (8 bits) make a byte (0-255)
two bytes (16 bits) make a word (0-65535)
And what is 65535? well that's 64 kilobytes ... in computers 'Kilo' is 1024, because binary works in powers of 2, and 2^10 is 1024
64 kilobytes is the amount of memory a basic 8-bit system can access
6502 is 8 bit so it's best at numbers less than 256... it can do numbers up to 65535 too more slowly... and really big numbers will be much harder to do! - we can design our game round small numbers so these limits aren't a problem.
Numbers in Assembly can be represented in different ways.
A 'Nibble' (half a byte) can be represented as Binary (0000-1111) , Decimal (0-15) or Hexadecimal (0-F)... unfortunately, you'll need to learn all three for programming!
Also a letter can be a number... Capital 'A' is stored in the computer as number 65!
Think of Hexadecimal as being the number system invented by someone wit h 15 fingers, ABCDEF are just numbers above 9!
Decimal is just the same, it only has 1 and 0.
Another way to think of binary is think what each digit is 'Worth' ... each digit in a number has it's own value... lets take a look at %11001100 in detail and add up it's total
If a binary number is small, it may be shown as %11 ... this is the same as %00000011
Also notice in the chart above, each bit has a number, the bit on the far right is no 0, and the far left is 7... don't worry about it now, but you will need it one day!
But wait! I said a Byte could go from 0-255 before, well what happens if you add 1 to 255? Well it overflows, and goes back to 0!... The same happens if we add 2 to 254... if we add 2 to 255, we will end up with 1
this is actually usefull, as if we want to subtract a number, we can use this to work out what number to add to get the effect we want
The TMS9900 is a BIG ENDIAN machine... what's stranger is that byte operations (like MOVB) work with the TOP BYTE of the register.
The TMS9900 Addressing Modes
The TMS9900 has 8 different addressing modes... many are similar to much later systems... in addition it has 4 'effective modes' which are defined by using Reg 7 as a parameter
'Deferred' addressing is known as indirect addressing on other systems
Chibi Akumas V1.666 has taken over 350 hours of development, if you want to support my work, and learn all the secrets of the game's development, please back me on patreon!
Thanks to Homebrew Legends for help promoting my game!
Buy ChibiAkuma(s) games now!