====== The 6809 ====== Motorola launched its advanced 8-bit 6809 in 1977. It was a successor to the 6800 popular in embedded systems, and was mostly source-code compatible with it while offering many extra features. Due mainly to its late arrival it was never as popular as the 6502 and Z80 micros, but it could be found in the Dragon and Tandy Coco home Computers, as well as in less visible platforms such as the Vectrex console and several arcade cabinets including Defender. The 6809 has two [[Memory#bits|8-bit]] accumulators ([[Accumulators#A|A]] & [[Accumulators#B|B]]), two [[Memory:bits|16-bit]] index registers ([[Indexes:X|X]] & [[Indexes:Y|Y]]), and two 16-bit stack pointers ([[Stacks:U|U]] & [[Stacks:S|S]]) which can double as index registers. All the 8 and 16-bit user registers offer Load, Store, and Compare (fully signed) instructions across the four main addressing modes (Immediate, Direct Paged, Direct Extended, and Indexed). Unlike most Intel-derived chips it is a [[Memory:endian|Big-endian]] design. The 8-bit accumulators have the usual set of one and two operand arithmetic and logical instructions. They can be combined into the 16-bit D register which has basic instructions for [[AddSub#add|Add]]ition and [[Sub]]traction, and also is the destination for the unsigned [[Mul]]tiply of A & B. There are 16 different conditional [[Bra]]nches which can all have either 8 or 16 bit offsets, reaching any point in memory. Subroutines can be Branched to as well as [[Jmp|Jump]]ed to. The indexed addressing mode includes a mode with an offset from the Program Counter (8 or 16-bit), thus there is no barrier to writing fully position independent code. System registers are the Condition Codes ([[CC]]), Program Counter ([[PC]]) and the Direct Page register ([[DP]]). The DP provides the high 8 bits for an address specified in a single byte in Direct Paged addressing mode. The CC can have any or all bits set or reset at once with the [[ORCC]] and [[ANDCC]] immediate mode instructions. Otherwise no instructions are provided for manipulating the system registers directly. The [[Trf|Transfer]] and [[Exg|Exchange]] instructions must be used instead, which work on any pair of registers the same size. The User ([[U]]) and System ([[S]]) [[Stack|stacks]] can have any combination of registers [[Psh|Pushed]] or [[Pul|Pulled]] in a single instruction. Subroutine return addresses and interrupts use the System stack only, the User stack has no system function. As well as the standard Interrupt ([[Interrupts:IRQ|IRQ]]) and Non-maskable Interrupt ([[Interrupts:NMI|NMI]]) there is the Fast Interrupt ([[Interrupts:FIRQ|FIRQ]]) which gives faster response by only stacking the CC. There are three Software Interrupts with their own user-definable vectors. [[Addressing:indexed|Indexed addressing]] is very flexible, working across all four index registers with options for constant offsets (5, 8, or 16-bit), accumulator offsets (A, B or D), and automatic post-increment and pre-decrement (by 1 or 2). All indexed modes can optionally be made [[Addressing:indirect|Indirect]], where the operand provides the address of the true operand. [[Addressing:PCR|PC relative]] comes under the Indexed mode umbrella so is available with indirection, and there's also a plain address Indirect mode. The [[LEA|Load Effective Address]] instruction is used for initialising pointers to memory objects, or for performing simple arithmetic on index registers. It calculates the address of the operand as normal, but instead of loading a value from the address loads the address itself. Altogether the 6809 is a flexible and powerful programming platform that is a pleasure to use. Its weaknesses are its relatively few registers, and low [[Memory:clocks|clock speed]] and good but sub-optimal efficiency.