The processors
The Motorola MC6800 (1974) is the ancestor of the 6809. The MC6802 and MC6808 are the same instruction set (the 6802 adds 128 bytes of RAM and a clock, the 6808 only the clock).
The MC6801 and its ROM-less MC6803 add instructions, among them a hardware multiply. Hitachi’s CMOS HD6301 and HD6303 run the 6801 set plus six more
(XGDX, SLP and four read-modify-write instructions with an immediate byte) and trap on undefined opcodes. The viewer’s Processor choice offers these three sets: MC6800, MC6801 and HD6303 (HD6301 and HD6303 decode identically).
Programs are not binary-compatible with the 6809. The 6805, 68HC11 and 6811 are not decoded.
Statuses in the viewer: documented for an opcode in the chosen chip’s data sheet; illegal for every other opcode, shown as one .byte (the HD6303 traps through the vector at $FFEE;
what the MC6800 and MC6801 do with them is not described here — some are known to halt the MC6800, but no source was read).
Registers, flags and addressing
| Register | Size | Use |
|---|---|---|
A, B | 8 | Accumulators; on the 6801 and later together D (A high) |
X | 16 | The one index register |
SP, PC | 16 | Stack pointer (it points at the next free byte, and pushes decrement it) and program counter |
CC | 8 | Condition codes H I N Z V C in bits 5 to 0 (bits 7 and 6 read as 1) |
Addressing: immediate #$12 or #$1234; direct $12 (page zero: the high byte is always 0, there is no direct page register); extended $1234; indexed $12,x (the offset is an unsigned byte, 0 to 255, added to X);
relative bra $2010 (signed 8-bit); inherent. JMP and JSR have indexed and extended forms (JSR direct from the 6801). Words are big-endian. The 6800 spells the accumulator forms with the letter after the operation
(ldaa, staa, oraa, adda, suba…, negb). asl and lsl are the same opcode.
Interrupt vectors: $FFF8 IRQ, $FFFA SWI, $FFFC NMI, $FFFE RESET. $FFEE is the HD6303’s illegal-opcode trap.
Instructions
Opcodes are in hex; a row with several gives them in the order accumulator A, accumulator B (where the instruction has both) or immediate, direct, indexed, extended. Set: 6800 (all four chips), 6801 (MC6801 and later) or 6303 (HD6301 and HD6303 only). Cycles are the MC6800 data sheet’s; the 6801 and 6303 counts differ and are not given. Flags are those the instruction changes.
| Mnemonic | Set | Opcodes | Bytes | Cycles (6800) | Flags | What it does |
|---|---|---|---|---|---|---|
NOP | 6800 | 01 | 1 | 2 | – | No operation |
TAP | 6800 | 06 | 1 | 2 | H I N Z V C | A to CC |
TPA | 6800 | 07 | 1 | 2 | – | CC to A |
INX | 6800 | 08 | 1 | 4 | Z | Increment X |
DEX | 6800 | 09 | 1 | 4 | Z | Decrement X |
CLV | 6800 | 0A | 1 | 2 | V | Clear overflow |
SEV | 6800 | 0B | 1 | 2 | V | Set overflow |
CLC | 6800 | 0C | 1 | 2 | C | Clear carry |
SEC | 6800 | 0D | 1 | 2 | C | Set carry |
CLI | 6800 | 0E | 1 | 2 | I | Enable interrupts |
SEI | 6800 | 0F | 1 | 2 | I | Mask interrupts |
SBA | 6800 | 10 | 1 | 2 | N Z V C | A = A − B |
CBA | 6800 | 11 | 1 | 2 | N Z V C | Compare A with B |
TAB | 6800 | 16 | 1 | 2 | N Z V | B = A |
TBA | 6800 | 17 | 1 | 2 | N Z V | A = B |
DAA | 6800 | 19 | 1 | 2 | N Z V C | Decimal adjust A |
ABA | 6800 | 1B | 1 | 2 | H N Z V C | A = A + B |
LSRD | 6801 | 04 | 1 | – | N Z V C | Shift D right |
ASLD (LSLD) | 6801 | 05 | 1 | – | N Z V C | Shift D left |
XGDX | 6303 | 18 | 1 | – | – | Exchange D and X |
SLP | 6303 | 1A | 1 | – | – | Sleep until an interrupt |
BRA | 6800 | 20 | 2 | 4 | – | Branch always |
BRN | 6801 | 21 | 2 | – | – | Branch never |
BHI | 6800 | 22 | 2 | 4 | – | Higher (C and Z clear) |
BLS | 6800 | 23 | 2 | 4 | – | Lower or same |
BCC | 6800 | 24 | 2 | 4 | – | Carry clear |
BCS | 6800 | 25 | 2 | 4 | – | Carry set |
BNE | 6800 | 26 | 2 | 4 | – | Not equal |
BEQ | 6800 | 27 | 2 | 4 | – | Equal |
BVC | 6800 | 28 | 2 | 4 | – | Overflow clear |
BVS | 6800 | 29 | 2 | 4 | – | Overflow set |
BPL | 6800 | 2A | 2 | 4 | – | Plus |
BMI | 6800 | 2B | 2 | 4 | – | Minus |
BGE | 6800 | 2C | 2 | 4 | – | Greater or equal (signed) |
BLT | 6800 | 2D | 2 | 4 | – | Less than (signed) |
BGT | 6800 | 2E | 2 | 4 | – | Greater than (signed) |
BLE | 6800 | 2F | 2 | 4 | – | Less or equal (signed) |
TSX | 6800 | 30 | 1 | 4 | – | X = SP + 1 |
INS | 6800 | 31 | 1 | 4 | – | Increment SP |
PULA | 6800 | 32 | 1 | 4 | – | Pull A |
PULB | 6800 | 33 | 1 | 4 | – | Pull B |
DES | 6800 | 34 | 1 | 4 | – | Decrement SP |
TXS | 6800 | 35 | 1 | 4 | – | SP = X − 1 |
PSHA | 6800 | 36 | 1 | 4 | – | Push A |
PSHB | 6800 | 37 | 1 | 4 | – | Push B |
PULX | 6801 | 38 | 1 | – | – | Pull X |
RTS | 6800 | 39 | 1 | 5 | – | Return from subroutine |
ABX | 6801 | 3A | 1 | – | – | X = X + B (unsigned) |
RTI | 6800 | 3B | 1 | 10 | H I N Z V C | Return from interrupt |
PSHX | 6801 | 3C | 1 | – | – | Push X |
MUL | 6801 | 3D | 1 | – | C | D = A × B, unsigned |
WAI | 6800 | 3E | 1 | 9 | – | Push the state and wait for an interrupt |
SWI | 6800 | 3F | 1 | 12 | I | Software interrupt through $FFFA |
NEG NEGA NEGB | 6800 | 60 70 · 40 · 50 | 2 3 · 1 | 7 6 · 2 | N Z V C | Two’s complement |
COM … | 6800 | 63 73 · 43 · 53 | 2 3 · 1 | 7 6 · 2 | N Z V C | One’s complement |
LSR … | 6800 | 64 74 · 44 · 54 | 2 3 · 1 | 7 6 · 2 | N Z V C | Logical shift right |
ROR … | 6800 | 66 76 · 46 · 56 | 2 3 · 1 | 7 6 · 2 | N Z V C | Rotate right through carry |
ASR … | 6800 | 67 77 · 47 · 57 | 2 3 · 1 | 7 6 · 2 | N Z V C | Arithmetic shift right |
ASL … | 6800 | 68 78 · 48 · 58 | 2 3 · 1 | 7 6 · 2 | N Z V C | Shift left |
ROL … | 6800 | 69 79 · 49 · 59 | 2 3 · 1 | 7 6 · 2 | N Z V C | Rotate left through carry |
DEC … | 6800 | 6A 7A · 4A · 5A | 2 3 · 1 | 7 6 · 2 | N Z V | Decrement |
INC … | 6800 | 6C 7C · 4C · 5C | 2 3 · 1 | 7 6 · 2 | N Z V | Increment |
TST … | 6800 | 6D 7D · 4D · 5D | 2 3 · 1 | 7 6 · 2 | N Z V C (V and C cleared) | Test against zero |
CLR … | 6800 | 6F 7F · 4F · 5F | 2 3 · 1 | 7 6 · 2 | N Z V C | Clear |
JMP | 6800 | 6E 7E | 2 3 | 4 3 | – | Jump |
AIM | 6303 | 61 indexed · 71 direct | 3 | – | N Z V | AND an immediate byte into memory: aim #$0f,$40, aim #$0f,$40,x |
OIM | 6303 | 62 · 72 | 3 | – | N Z V | OR an immediate byte into memory |
EIM | 6303 | 65 · 75 | 3 | – | N Z V | Exclusive OR an immediate byte into memory |
TIM | 6303 | 6B · 7B | 3 | – | N Z V | Test memory against an immediate byte |
SUBA SUBB | 6800 | 80 90 A0 B0 · C0 D0 E0 F0 | 2 2 2 3 | 2 3 5 4 | N Z V C | Subtract |
CMPA CMPB | 6800 | 81 91 A1 B1 · C1 D1 E1 F1 | 2 2 2 3 | 2 3 5 4 | N Z V C | Compare |
SBCA SBCB | 6800 | 82 92 A2 B2 · C2 D2 E2 F2 | 2 2 2 3 | 2 3 5 4 | N Z V C | Subtract with borrow |
SUBD | 6801 | 83 93 A3 B3 | 3 2 2 3 | – | N Z V C | Subtract from D |
ANDA ANDB | 6800 | 84 94 A4 B4 · C4 D4 E4 F4 | 2 2 2 3 | 2 3 5 4 | N Z V | AND |
BITA BITB | 6800 | 85 95 A5 B5 · C5 D5 E5 F5 | 2 2 2 3 | 2 3 5 4 | N Z V | Bit test |
LDAA LDAB | 6800 | 86 96 A6 B6 · C6 D6 E6 F6 | 2 2 2 3 | 2 3 5 4 | N Z V | Load accumulator |
STAA STAB | 6800 | 97 A7 B7 · D7 E7 F7 | 2 2 3 | 4 6 5 | N Z V | Store accumulator |
EORA EORB | 6800 | 88 98 A8 B8 · C8 D8 E8 F8 | 2 2 2 3 | 2 3 5 4 | N Z V | Exclusive OR |
ADCA ADCB | 6800 | 89 99 A9 B9 · C9 D9 E9 F9 | 2 2 2 3 | 2 3 5 4 | H N Z V C | Add with carry |
ORAA ORAB | 6800 | 8A 9A AA BA · CA DA EA FA | 2 2 2 3 | 2 3 5 4 | N Z V | OR |
ADDA ADDB | 6800 | 8B 9B AB BB · CB DB EB FB | 2 2 2 3 | 2 3 5 4 | H N Z V C | Add |
ADDD | 6801 | C3 D3 E3 F3 | 3 2 2 3 | – | N Z V C | Add to D |
CPX | 6800 | 8C 9C AC BC | 3 2 2 3 | 3 4 6 5 | N Z V | Compare X with memory (the HD6303 also changes C: see the checks) |
BSR | 6800 | 8D | 2 | 8 | – | Branch to subroutine |
LDS | 6800 | 8E 9E AE BE | 3 2 2 3 | 3 4 6 5 | N Z V | Load the stack pointer |
STS | 6800 | 9F AF BF | 2 2 3 | 5 7 6 | N Z V | Store the stack pointer |
JSR | 6800 (direct: 6801) | AD BD · direct 9D | 2 3 | 8 9 | – | Jump to subroutine |
LDD | 6801 | CC DC EC FC | 3 2 2 3 | – | N Z V | Load D |
STD | 6801 | DD ED FD | 2 2 3 | – | N Z V | Store D |
LDX | 6800 | CE DE EE FE | 3 2 2 3 | 3 4 6 5 | N Z V | Load X |
STX | 6800 | DF EF FF | 2 2 3 | 5 7 6 | N Z V | Store X |
How this was checked
- The MC6800 decoder’s opcodes, lengths, registers, flags, memory use, branch targets and cycle counts are compared with the executing core in
emulators.org/emulator/williams/src/m6800.js(4,656 executions): no difference, except that this core takes one cycle too few for indexedLDS,STS,LDXandSTX(the data sheet says 6, 7, 6, 7). - The HD6303 decoder is run against the Psion Organiser II’s HD6303 core (
emulators.org/emulator/jape-psion/src/hd6303.js; 5,400 executions) for the whole 6801 and 6303 sets: lengths, registers, flags, memory use; and compared opcode by opcode with the debugger’s ownhd6301.jsdecoder. That core also changes C inCPX, which the MC6800 data sheet does not.
Not described
- What the MC6800 and MC6801 do with undefined opcodes, the 6801’s cycle counts and the 6801’s on-chip timer and serial registers, the 6802’s RAM, the 6805, 68HC11 and 6811.
- The HD6303’s
TRAPsequence beyond the vector address.