/emu6809

Emu6809: Motorola 6809 Emulator in FORTH

Primary LanguageForthGNU General Public License v3.0GPL-3.0

Emu6809: Motorola 6809 Emulator in FORTH

Introduction

This is a 6809 emulator written in gForth. You can load a 6809 binary rom and run it or step through.

Interupt related instructions are not implemented (CWAI, RTI,SWI, SWI2, SWI3, SYNC).

It is not cycle accurate.

Status: Passes MC6809 CPU Test Suite by W. Schwotzer

How to use

I have written some instructions here.

Challenges

Some things that make this emulator more challenging than Emu6502:

  • Indirect addressing & the postbyte register bit assignments, Fig 16 page 17 of the datasheet
  • Some opcodes are 2 bytes long (10xx and 11xx), which break the simple opcode table and opcode decoding mechanism implemented in Emu6502. Impacts: OPCODES2 & BIND2 + new logic for FETCH and DECODE
  • Some instructions manipulate 16 bit values while other manipulate 8 bit values. Impacts low level words like >N which now needs a 16-bit version (>NW)
  • Some instructions manipulate both 8 and 16 bit registers. Impacts is additional logic is needed in higher level words (like in TFR, EXG...)
  • Flag handling (like overflow V or half-carry H) in Condition Code Register
  • Books from the era have many uncorrected erratas (from wrong information about flags used in instructions to non-existant addressing modes!)

References

Tests suites: