|The 6800 was too
expensive for the mainstream, and it had many of its features cut, and
was released as the 6502... it's second accumulator gone, it's
command set cut back - and everyone forgot about the 6800....
But the 6800 came back - as the 6809... with new previously unheardof powers!... armed with twin stack pointers , 16 bit Stack,X and Y registers- 16 bit capabilities and advanced addressing modes and even a MULTiply command (unheard of in most 8 bits)... the 6809 is the 'missing link' between the 6502 and the 68000!
Powering the Dragon 32, the FM-7 machines - and more significantly the Vectrex... Lets see what the 6809 can do!
|If you want to learn 6809 get the Cheatsheet! it has all the 6809 commands, It will give you a quick reference when you're stuck or confused, which will probably happen a lot in the early days!|
using Macroassembler AS for our assembly in these tutorials... VASM is
an assembler which supports rarer CPU's like 6809 and 65816 and many more, and
also supports multiple syntax schemes...
You can get the source and documentation for AS from the official website HERE
probably think 64 kilobytes doesn't sound much when a small game now
takes 8 gigabytes, but that's 'cos modern games are sloppy,
inefficient, fat and lazy - like the basement dwelling losers
who wrote them!!!
6809 code is small, fast, and super efficient - with ASM you can do things in 1k that will amaze you!
will use a symbol to denote a hexadecimal number, some use $FF or #FF
or even 0x, but this guide uses & - as this is how hexadecimal
represented in CPC basic
All the code in this tutorial is designed for compiling with WinApe's assembler - if you're using something else you may need to change a few things!
But remember, whatever compiler you use, while the text based source code may need to be slightly different, the compiled "BYTES' will be the same!
|Digit Value (D)||128||64||32||16||8||4||2||1|
|Our number (N)||1||1||0||0||1||1||0||0|
|D x N||128||64||0||0||8||4||0||0|
|128+64+8+4= 204 So %11001100 = 204 !|
|If you ever get confused, look
at Windows Calculator, Switch to
'Programmer Mode' and it has binary and Hexadecimal view, so
change numbers from one form to another!
If you're an Excel fan, Look up the functions DEC2BIN and DEC2HEX... Excel has all the commands to you need to convert one thing to the other!
|Equivalent Byte value||255||254||253||251||246||236||206||2||1|
|Equivalent Hex Byte Value||FF||FE||FD||FB||F6||EC||CE||2||1|
these number types can be confusing, but don't worry! Your Assembler
will do the work for you!
You can type %11111111 , &FF , 255 or -1 ... but the assembler knows these are all the same thing! Type whatever you prefer in your ode and the assembler will work out what that means and put the right data in the compiled code!
|Inherant Addressing||Commands that don't take a parameter||ABX|
|Regsiter Addressing||Commands that only use register||TFR A,DP|
|Immediate Addressing||Direct Address of command||ADDA #$10
|Direct Page addressing||Read from DP (zero page||ADDA $10|
|Extended Direct addressing||Read from an address||ADDA $1234|
|Extended Indirect Addressing||Read from the address specified... then get the value from that address||ADDA [$1234]|
|Indexed Addressing||Uses a 2nd setting byte - allows for Autoinc||,R
|Zero Offset||Just use the address in the register||LDA ,Y
|5 bit offset||-16 to +15 offset||LDA -1,Y|
|Consant offset from base register||8 / 16 bit offset from X,Y,U,S ... Can be negative or positive||LDA 1000,Y|
|Constant Offset From PC||8 / 16 bit offset from PC||LDA $10,PC|
|Program counter relative||PCR is like PC, but is calculated by the assembler||ADDA label,PCR|
|Indirect with constant offset from base register||Load from the address in the register + offset||LDA [1,X]|
|Accumulator offset from Base register||Add accumulator (A/B/D) to a X,Y,U,S (not PC)||LDA B,Y|
|Indirect Accumulator offset from Base register||Load from the address made up of a X,Y,U,S Plus the accumulator||LD [B,Y]|
|AutoIncrement||Add 1 or 2 to the register||ADDA ,X+
|AutoDecrement||Subtract 1 or 2 from the register||ADDA ,-X
|Indirect AutoIncrement||Load from the address in Register, then add 1 or 2||ADDA [,X+]
|Indirect AutoDecrement||Subtract 1 or 2 then Load from the address in Register||ADDA [,-X]
|Program relative||Offset to PC||BRA label|
|Mode||Description||Sample Command||Z80 Equivalent||effective result|
|Implied / Inherant||A command that needs no paprameters||SEC||SEC (set carry)||SCF|
|Relative||A command which uses the program counter PC with and offset nn (-128 to +127)||BEQ #$nn||BEQ [label] (branch if equal)||JR Z,[label]|
|Accumulator||A command which uses the Accumulator as the parameter||ROL||ROL (ROtate bits Left)||RLCA|
|Immediate||A command which takes a byte nn as a parameter||ADC #$nn||ADC #1||ADC 1||&nn|
|Absolute||Take a parameter from a two byte memory address $nnnn||LDA $nnnn||LDA $2000||LD a,(&2000)||(&nnnn)|
|Absolute Indexed||Take a parameter from a two byte memory address $nnnn+X (or Y)||LDA $nnnn,X||LDA $2000,X||(&nnnn+X)|
|Zero Page||Take a parameter from the zero page address $00nn||ADC $nn||ADC $32||(&00nn)|
|Zero Page Indexed||Takes a parameter from memory address $00nn+X||ADC $nn,X||ADC $32,X||(&00nn+X)|
|Indirect||Take a parameter from pointer at address $nnnn...
if $nnnn contains $1234 the parameter would come from the address at $1234
|JMP ($1000)||LD HL,(&1000)
|indirect ZP||The 65c02 has an extra feature, where it can read from an unindexed Zero page||LDA ($80)||((&00nn))|
|Pre Indexed (Indirect,X)||Take a paramenter from pointer at address $nnnn+X
if $nnnn contains $1234, and X contained 4 the parameter would come from the address at $1238
|ADC ($nn,X)||ADC ($32,X)||((&00nn+X))|
|Postindexed (Indirect),Y||Take pointer from address $nnnn, add Y... get the
parameter from the result
if $nnnn contains $1234, and Y contained 4, the address would be read from $1234... then 4 would be added... and the parameter would be read from ther resulting address
|ADC ($nn),Y||ADC ($32),Y||((&00nn)+Y)|
|12345||(16384)||decimal memory address|
|$||$4000||(&4000)||Hexadecimal memory address|