stevenvh.net

Electronics

The MC6809 microprocessor

Introduction

I grew up with microprocessors. They had been available for some years — the Mother of All Microprocessors, the Intel 4004, was released in 1971 — but by the middle of the decade microprocessors became available for hobbyists, and consumer products with a microcontroller inside came to market.

Texas Instruments TI-57 programmable calculator

My first experience with programming was when I got a programmable calculator, the Texas Instruments TI-57, in 1977. (I had told my mom I absolutely needed it for school.) It could hold a program of maximum 50 instructions in volatile memory, i.e. your program was gone when you switched of the device. But it was a good way to learn the first steps of programming.
Later I got a TI-58, which was more advanced, and had for instance program libraries for specific tasks.

Around the time I went to college, in 1979, I started with general-purpose microprocessors, like the Zilog Z-80, and the Motorola MC6802. (Note: I'll refer to the MC6800 and MC6802 interchangeably as they have the same programming model. The MC6802 has 128 bytes of on-chip RAM, though, which is not present on the MC6800.)
The first hobbycomputers came to market. Some had their own — CRT — display unit; other had to be connected to a TV set. But all used BASIC as their programming language, which was convenient for the owner of the machine, but it also obfuscated the microcontroller inside.
I bought an experimenter board around the Z-80, which had to be programmed in machine language via a very basic (no pun intended) keypad and ditto display. Well, you wrote the program in assembly language, but you assembled the code by hand.

In college we had similar experimenter boards, but this time built around the Motorola MC6802. Once you had some experience with one microprocessor a new one didn't pose much difficulty; you just had to learn the new machine codes.

In 1980 Radio Shack (known as Tandy in Europe) released a new hobby computer, the TRS-80 Color Computer, aka COCO, in 1983 followed by a Mark II model. Radio Shack had made a rather successful TRS-80 before, built around the Zilog Z-80, but despite the similar name the Color Computer was a complete different machine. Whereas the TRS-80 had a monochrome display, with very elementary block graphics, the CoCo had color pixel graphics. I bought a Color Computer 2 in 1983. (IBM's PC had already been released in 1981, but was way too expensive for a college student like me.)

Another difference between the TRS-80 and the CoCo was the microprocessor used. Whereas the former used the Z-80, the CoCo was equipped with a Motorola MC6809, the successor of the MC6802.

Microprocessor characteristics

There is a number of factors which determine the performance of a microprocessor. There's clock frequency, say the speed. Computers from the era were slow, typically running on a clock between 1 and 2 MHz. (Today's PCs are around 1000 times faster.)

There is the word width; the number of bits used to represent a basic information unit. The first microprocessors were 4-bit, and the TI-57 and TI-58 calculators had 4-bit cores. With four bits you can have 16 combinations, enough to represent a decimal digit. And good enough for a calculator.

A 6809 in DIL package
But a general-purpose computer also has to handle text, and to represent all letters from the alphabet, the digits, and some extra symbols you got way more than 16 combinations. And the microprocessors became 8-bit (good for 256 possible combinations).

The MC6809

"The MC6809 has the most complete set of addressing modes available on any 8-bit microprocessor." (datasheet)

I don't know anybody who worked with the 6809 and didn't speak of it in superlatives. "Most elegant processor ever" is one I heard many times.

"Motorola had played around with the 68000 design and decided not to go forward aggressively with that. Instead, they did the best 8-bit processor ever done, the 6809."

— Bill Gates, interview

The 6809 is a remarkable microprocessor. Yes, it did have the most addressing modes of any 8-bit processor, but that's only part of its superiority in the 8-bit world. It has a very complete register set, and combined with the addressing modes and an orthogonal instruction set it has 1464 distinct instructions. Overmore, it was designed with high-level languages (C!) in mind, and allowed relocatable (position-independent) and re-entrant code. All of which allowed Microware to develop an excellent operating system for the 6809: OS-9.

The MOS6502, MC6800 and MC6809 compared

I already mentioned the programming model. The 6809 has two 16-bit index registers, and two 16-bit stack pointers, for instance. Two 8-bit accumulators which combine into a 16-bit accumulator. That makes the 6809 a hybrid of an 8-bit and a 16-bit microprocessor.

MC6809 Programming Model

The 6502's programming model looks rather pale in comparison: all registers are only 8 bit wide, and there's only one accumulator and one stack pointer.

MOS6502 Programming Model

In the following table the 6502 and 6809 are shown side-by-side, with the MC6802 added for good measure.

Characteristic 6502 6802 6809
Number of transistors 3500 4000 9000
Databus width in bits 8 8 8
Addressing range in kB 64 64 64
Addressing modes 7[1] 6 14
Total instruction/addressing mode combinations 151 195 1464
Registers 6 6 10
Number of accumulators 1 2 2
Number of index registers 1 1 2
Index register width in bits 8 8 16
Number of stack pointers 1 1 2
Stack pointer width in bits 8 16 16
Direct(zero) page register No No Yes
SEX instruction ;-) No No Yes
Total bits in register 55 71 112
On-chip RAM in bytes 0 128 0

[1] You'll often find 13 as the number of addressing modes. If you take a closer look at those 13 you'll see that MOS counts Indexed-X and Indexed-Y as separate addressing modes, which is a joke. If Motorola would count the same way the 6809 will easily reach 20 addressing modes; indeed indexing can be done on all 4 index registers and stack pointers. And it could count operations on accumulator A and B separately, for instance.

Orthogonality

An orthogonal ISA is an architecture where register set, instruction set, and addressing modes are very much independent of each other. This means that an instruction for one register has an equivalent instruction for any other register. Unlike the 6502, the 6809 is highly orthogonal, which accounts for the large number of instruction/addressing modes. But orthogonality comes at a price: the completeness needs more transistors which results in a higher price.

Timing

Processor # bits Time Time
normalized[1]
6502 @ 1MHz 8 13.9 13.9
Z80 @ 4 MHz 8 6.8 27.2
6809 @ 2 MHz 8/16[2] 5.1 10.2
8086 @ 8 MHz 16 1.9 15.2
68000 @ 8 MHz 16 0.49 3.92
[1] Normalized to 1 MHz clock the 6809 outperforms the other 8-bitters, and even the 16-bit 8086. Isn't that cheating? The 6809 could never run at 8 MHz. No, it's not cheating; it shows the power of the microprocessor's logic, independent of the electronic implementation.
[2] While the 6809 has an 8-bit databus most of its registers are 16 bit, including the double accumulator D. Note that the 8088 is also referred to as a 16-bit processor, while it also has an 8-bit wide databus.

Where did it go wrong?

  1. The market had already settled on the 6502 and Z80.
  2. The 6809 was way more expensive than other 8-bit microprocessors.
  3. Poor marketing by Motorola.
  4. It came too late; 16-bitters were right around the corner.