13

What are some some tracing disassemblers for the Z80? I.e., disassemblers that will trace through the code and disassemble as instructions only the areas it traces through, leaving the rest as data. (This question and its answers do not discuss tracing, which is a key criterion for me.)

Note that I'm disassembling native assembly language here, not code from a high-level language compiler.

Ideally it would also provide something that would let me mark particular functions that take data after a call instruction and return past the data.

I ask because I'm currently reverse-engineering an old CP/M program (dating from 1981) that makes heavy use of arguments to subroutines as data after the call, where the subroutine then updates the return address to after those data bytes before returning.

Ideally I'd like a command-line disassembler that runs on Unix, but I'm open to ones that run on other systems, or even use a GUI.

In your answer, if you know the details, it would be good to give a little information about the disassembler. For example, is it command-line- or GUI-based? What platforms does it run on? Are the annotation files in a text format that can be edited, or do you need to use that program's editor?

11
  • 7
    To whomever voted to close as "opinion based," I don't think it's a matter of opinion whether a program is a Z80 disassembler, or not, nor is it a matter of opinion whether a disassembler is a tracing disassembler.
    – cjs
    Apr 17 at 9:25
  • 2
    You might want to have a look here (if not at least partially duplicate): retrocomputing.stackexchange.com/questions/20257/… And: You will definitively want to have a GUI, as being able to interactively hint the disassembler to certain things can greatly improve the results.
    – tofro
    Apr 17 at 9:29
  • 2
    @cjs while not my vote, I can quite see that reason, as the base of that question is asking for a 'suggestion' which is by default a personal opinion. Using a different wording, like by simply asking for existence, may suitable weaken that aspect. Beside that the result would most likely be a modern tool. Upvoted as I would like as well to see what's out there.
    – Raffzahn
    Apr 17 at 12:07
  • 1
    @cjs wouldn't that go for any level of language? After all, even English is able to form clear unmistakable sentences, isn't it? Modern tools are simply that - way off the real thing. More important, there are of course contemporary tools that may or may not have offered that. I fondly remember one i used for y86 (sourcerer?) which, while not tracing or GUI, supported a quite fast paced interactive style for similar constructs. So I wouldn't be too surprised if something like it existed for 8080/Z80.
    – Raffzahn
    Apr 17 at 12:55
  • 1
    Well, Ghidra does tracing, and all manner of code analysis. But you'd hate it because it's a 300 MB download of a GUI that needs another 300 MB of JDK to run it. I do read the questions, btw: I'm surprised that my duplicate close flag put that comment in there
    – scruss
    Apr 18 at 1:52

3 Answers 3

10

Maintainer of the Reko project here. Reko does tracing disassembly of various processors, including Z80. Depending on the file format, you may need to specify a specific loading address (since Z80 code is not position-independent).

Reko is available for any platform that can run .NET 6.0 programs. This includes Linux, MacOS, and Windows platforms. On Windows it's available as a GUI program and as a command-line program. On Linux, only as a command-line program. A cross-platform GUI is under development.

Annotations can be added as a C-style header file:

[[reko::address("0204")]] 
    [[reko::returns(register, "bc")]] int16
     my_fun(
        [[reko::arg(register, "hl")]] char *);

(see https://github.com/uxmal/reko/blob/master/doc/guide/usermetadata.md for more examples)

As for the specific calling convention you are mentioning, where argument data is provided inline in the instruction stream after the call instruction: Reko has no support for it yet, but I'd be happy to discuss with you what your expectations for such a feature would be.

1
  • Initially I could do with simply being able to declare that specific subroutines take zero-terminated data after the CALL. Things could probably get more sophisticated than that, but that seems to be by far the most common case.
    – cjs
    Apr 17 at 12:24
9

IDA is a well-known tracing disassembler which supports the Z80. Usually Z80 support is a paid feature not available in free versions, but the freeware version 3.7 from 1997 includes Z80 support. IDA 3.7 is an interactive DOS program with a Turbo Vision style user interface; it can be run in DOSEMU under Linux.

While IDA 3.7 does not support automatically parsing inline arguments, it is possible to mark a function as not returning so that the bytes following the CALL are not disassembled. Searching for unclassified bytes (Ctrl+U) will then let you jump to each call to the function and mark the following bytes as data.

6

I use Ghidra for such purposes, but I have to admit that I just started. It supports an astonishing long list of targets, even the 8051 of the first project I used it for. Its automatic analysis works well, at least what I saw until now.

It has a steep learning curve, as any complex tool. Don't work against the suggested workflow, just because you are used to another one, work with it and extend your "tool box."

Plugins allow to enhance analyses even more. Currently I'm working on an ARM Cortex M0 target, where several peripheral definitions can be loaded from (textual) definition files.

For a non-mouse-pusher like me its keyboard shortcuts speed up analyses a lot. I haven't invested the time yet to look how to setup more shortcuts. Especially jumping back and forth through references is most helpful.

Oh, and I'm working on another program targeting the Z80 in the ZX81.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .