Thursday, August 30, 2018

and the processor wars discussion leads to...

The 'Processor Wars' discussion led to a few changes in the regular bitmap code for the 6803 and Z80.

The 6803 bitmap code isn't as efficient as it's Plus/4 screen layout version, but it cut the number of X register swaps in half.  This saves 16 clock cycles in the print two character code, and 12,288 clock cycles per screen of characters (16 clock cycles x 32 bytes per row x 24 rows of characters).  More importantly, the code is still faster after switching from a 7 byte font to an 8 byte font to support full height graphics characters.  Writing single characters does not benefit, but that should only happen at the start or end of a string where two characters are not aligned on a byte.  This also puts the .89 MHz 6803 closer to the speed of the 1.77 MHz 65816 Atari, and 3.5 MHz Z80 VZ.

The Z80 code had not been updated to increment the font pointers using byte instead of 16 bit opcodes in spite of the fact that I came up with the optimization years ago.  Not sure what happened there, but for some reason it wasn't in the code.  This requires aligning the font data so that individual characters do not cross a 256 byte boundary, but it appears to cut 2 clock cycles per register increment, and there are 14 of those per pair of bytes, or 7 when printing single bytes.  That's up to 21,504 clock cycles per screen of characters (2 clock cycles * 14 increments * 32 bytes per row * 24 rows of characters).

The 6502 code won't benefit from either of these optimizations.  It only has a single accumulator, and it doesn't have any 16 bit registers.  The 65816 might be able to speed up address calculation, and the larger index registers may help, but it's going to take some time to see if that's possible with the mode 8/16 bit switching.  If it is, it will probably mean splitting the 6502, and 65816 versions up to make it easier to maintain the code.  It's a bit complex already due to squeezing Atom, Atari, and Commodore versions in the same code base.

*edit*
The 65816 could save two opcodes during the screen address calculation, but it would require at least as many new opcodes for the 8->16->8 bit mode switches.

No comments:

Post a Comment