1

I'm working on some Ghidra loader and filesystem modules for 80s microcomputers.

I started work on a Loader for .cas tape image files for the TRS-80 CoCo because Ghidra suports the 6805 CPU. (It also supports the M68HC05TB and MC68HC908QY4)

I never used the CoCo or anything with a 6809 back in the day so wasn't accustomed to its instructions. I am used to a few other instruction sets though. Anyway I assumed 6805 and 6809 would be quite that using Ghidra for CoCo and Dragon 32 binaries would be useful.

But when I got my loader module to the point it was ready to test I found it did not produce code for the CoCo's ROM that matched disassemblies on the Internet. Many bytes could not be decoded into instructions at all.

But when I search for the 6805 I can't find information saying the instruction sets are substantially different, though they only give the impression it should be quite close to the 6809 rather than outright saying it.

So have I made a wrong assumption, have I mixed something up on Ghidra, or do the two similarly named chips have totally different instruction sets? Should I be able to disassemble code for these '80s machines using Ghidra if I set it properly?

(I'm sure there are other disassemblers but I'm only working with Ghidra for this project.)

1

Ghidra currently does not support the 6809 and there is not yet a feature request for it.

The 6805 and 6809 do have related instruction sets and opcodes but are neither forward nor backward compatible at a binary level.

In particular, the 6809 has two prefix opcodes: $10 "page 1" and $11 "page two". These are very common in 6809 code.

But on the 6805 and many of the chips ending in a smaller number the opcodes $10 and $11 are used for other instructions. On the 6805, $10 is BSET and $11 is BCLR.

There seem to be quite a few other differences but a side-by-side list of opcodes is not easy to find. In general, both chips have variable length instructions with some same opcodes used for different length instructions, so any attempt to use a tool for one chip on binary code for the other will get out of sync very quickly.

HOLD THE PRESSES!

About one minute after posting this answer as a result of a few hours of research I made a confusing discovery:

According the the Ghidra source on GitHub, 6809 support was added in November 2019. You can see in the directory for the 6805 support:

https://github.com/NationalSecurityAgency/ghidra/tree/master/Ghidra/Processors/6805/data/languages

6809.cspec    Support Motorola M6809  7 months ago  
6809.pspec    Support Motorola M6809  7 months ago  
6809.slaspec  GT-3483: fixed sleigh error in 6x09 language spec.  5 months ago

I'm using Ghidra version 9.1.12, released in February 2020 so this functionality should be there. Either it's missing due to a bug or I simply can't find the way to use it. It does not appear in the list of "languages" and there is no related option if you choose 6805 as the language.

I've filed issue #1958 on Ghidra: https://github.com/NationalSecurityAgency/ghidra/issues/1958

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.