6809

From SizeCoding
Jump to: navigation, search

Introduction

Wanting to start sizecoding on a 6809 platform in this day and age can be tough. So here is a bit of help to get you started:

6809 Based Plaforms

The 6809 CPU

Registers

These are the internal registers of the 6809:

  • A + B (D): Two 8-bit accumulators which can be combined into one 16-bit accumulator.
  • X + Y: Two 16-bit index registers.
  • S + U: Two 16-bit stack pointers, which can also be used as index registers.
  • PC: 16-bit Program Counter
  • DP: 8-bit Direct Page value, a pointer to a page in RAM to set the Direct Page (Moveable Zero Page)
  • CC: 8-bit Condition Codes

Instruction Set

The 6502's instruction set was inspired by the 6800 series (Predecessor to the 6809), so there are a few similarities between the two. If you are coming from a 6502 background, you may get the jist of it sooner than others.

Here is a handy sheet with all the instructions of the 6809: https://www.chibiakumas.com/6809/CheatSheet.pdf

Techniques

Stack Blasting

The 6809 has quick methods of pushing and pulling registers onto and off the stack, which only take 5 cycles plus one per byte you are pushing/pulling. This can be used for fast memory copying.

Although the 6809 does have auto-incrementing it can take up to 16 cycles per two bytes to copy. With stack blasting we can speed it up to 7 bytes in 24 cycles.

Due to using almost every register you will have to back up certain registers before utilising this method.

;The conventional method:
LDX #SOURCE
LDY #DESTINATION
LDD ,X++
STD ,Y++

;Stack blasting:
LDS #SOURCE
LDU #DESTINATION
PULS D,X,Y,DP
PSHU D,X,Y,DP

General 6809 Resources