Quantcast
Channel: stardot.org.uk
Viewing all articles
Browse latest Browse all 5552

development tools • Re: NARD: Not A Real Disassembler

$
0
0
Thanks julie_m,
a tool such this on the toolbox is sure useful.
As I am curious (bad trait, I know): would you mind to elaborate further on what the original problem was?
I was working on an improved version of DFSBuster, which was a utility I created for handling DFS disc images. While it was good at doing what it did, I really wanted to make a neater, object-oriented implementation of the DFS functionality that would be more easily reusable. And I thought it would be nice to do something better than the original, rudimentary "automatic file type detection", which just treated anything with an execution address between &8000 and &80FF as a BASIC program. A file with a load address of &3000 and a length of &5000 is most probably a MODE 0/1/2 screen, &5800 + 2800 could be a MODE 4/5 screen, and so forth. If the execution addresses differs from the load address, that's obviously a machine code program. Except not everyone puts their subroutines at the beginning and their main loop later on. Bother. Well, if the execution address differs from the load address OR the byte there is a valid instruction ..... Nope, false positives all over the place. There are 151 valid opcodes; that's 59% of the total search space, so any byte is more likely to look like code than not.

After much wailing and gnashing of teeth, and applying Polyfiller to the forehead-shaped dent in the table, I came to the conclusion that the only way to do this satisfactorily was going to be to do it properly. Any chunk of valid executable code should always end with an RTS, and the next location after that doesn't have to be valid. Well, except when it ends with RTI. Or JMP (which, if you think about it, is still going to lead ultimately to an RTS). Or one of the B instructions. And the realisation that the hash I had created, indicating which byte values were valid instructions and how many extra bytes each one expected, was already most of the bones a simple disassembler.

By the time I had it displaying instructions on screen, Exmon-style, I was already determined to do something else with it.

If you liked it, there will be a new version shortly. I might as well start another GitHub for it .....

Statistics: Posted by julie_m — Thu Oct 02, 2025 11:46 pm



Viewing all articles
Browse latest Browse all 5552

Trending Articles