|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 unheard-of 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!|
|We'll be 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
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!
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 is 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 you can change numbers from one form to
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|
|All 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|
|12345||(16384)||decimal memory address|
|$||$4000||(&4000)||Hexadecimal memory address|
|DEX/DEY/INX/INY||Tfr X,D ;replace X with Y if required
DecB ;or IncB as required
Tfr D,X ;replace X with Y if required