BeebDis updates

discuss pc<>acorn file transfer issues and the use of other utils
Post Reply
Prime
Posts: 2861
Joined: Mon Jun 01, 2009 12:52 am
Contact:

BeebDis updates

Post by Prime » Sat Apr 21, 2018 10:33 pm

Hi all.

Just a post to let people know that BeebDis has now reached version 1.20.

This now includes the facility to disassemble 6502, 65c02, wd65c02 and Motorola 6809 code.
I've now split out the disassembler code into processor specific and generic parts which should make adding of other CPU targets easier.
I've also implemented an internal configuration system where some assembler output settings can be overridden in the control file.
The disassembler now also has the facility to process os9 and DragonDos/DragonMMC executable modules, taking start addresses etc from the header.

As always source of latest version can be found at : https://github.com/prime6809/BeebDis

Feel free to report any bugs or let me know any suggestions you may have.

Cheers.

Phill.

User avatar
hoglet
Posts: 9237
Joined: Sat Oct 13, 2012 7:21 pm
Location: Bristol
Contact:

Re: BeebDis updates

Post by hoglet » Sun Apr 22, 2018 10:11 am

Hi Phill,

Thanks for all this work.

I've used BeebDis again in anger over the last few days, doing a disassembly of BBC Basic 4r32:
https://github.com/hoglet67/BBCBasic4r3 ... isassembly

I'm a huge fan of BeebDis, and the recent changes have made it much quicker/easier to use. I've also been able rebuild from source successfully on both Linux and Windows.

Here's a log of a few issues I hit doing the BBC Basic 4r32 disassembly:

1. Incorrect mnemonics are output for for INC A and DEC A on the 65C02 - these are emitted as just INC and DEC, which is incompatible with BeebAsm.

2. Extracted string values containing the double quote (") character are malformed, because the double quote is not escaped in any way.

For example, there is a small embedded tokenized basic program at b2e9:

Code: Select all

0000b2e0                              f6 3a e7 9e f1 22 20  |........`.:..." |
0000b2f0  61 74 20 6c 69 6e 65 20  22 3b 9e 3a e0 8b f1 3a  |at line ";.:...:|
0000b300  e0 0d                                             |.. 2....*H.+H. q|
I tried to extract this with STRINGTERM $b2e9 13 and it almost worked, apart from the double quote characters.

3. When extracting a table of addresses using:

Code: Select all

word pc 114
it would be nice to have a flag to allow these to be added automatically as code entry points. That would shorten the control file considerable.

4. More of an observation, but the newer versions of BeebDis does tend to be much more liberal with labels than the older versions. In some cases labels are defined, but never referenced. This makes it harder to spot code that is not obviously reachable.

I ended up cleaning up the output with a script:

Code: Select all

# Remove unreferenced labels
# (BeebDis is very liberal with labels)
grep "^\.L[89AB][0-9A-F][0-9A-F][0-9A-F]" Basic432.asm | cut -c2- > labels
for i in `cat labels`
do
    hits=$(grep -c $i Basic432.asm)
    if [ "$hits" == "1" ]; then
        echo "Removing $i"
        grep -v "$i" Basic432.asm > x
        mv x Basic432.asm
    fi
done
rm -f labels
I think the issue is that everything you add to the control file results in a label, even if that is not intended and there are no references to it.

Anyway, thanks again for a very nice tool!

Dave

Prime
Posts: 2861
Joined: Mon Jun 01, 2009 12:52 am
Contact:

Re: BeebDis updates

Post by Prime » Sun Apr 22, 2018 3:56 pm

hoglet wrote:Hi Phill,

I'm a huge fan of BeebDis, and the recent changes have made it much quicker/easier to use. I've also been able rebuild from source successfully on both Linux and Windows.
Being able to compile on multi platforms was the reason for using Lazarus / Freepascal rather than Delphi, as it will run on anything that they will run on..... But good to know someone else has cross compiled, I do check on Linux and Macos periodically, but don't generally use it on those platforms.
Here's a log of a few issues I hit doing the BBC Basic 4r32 disassembly:

1. Incorrect mnemonics are output for for INC A and DEC A on the 65C02 - these are emitted as just INC and DEC, which is incompatible with BeebAsm.
Right fixed in source will push later.
2. Extracted string values containing the double quote (") character are malformed, because the double quote is not escaped in any way.

For example, there is a small embedded tokenized basic program at b2e9:

Code: Select all

0000b2e0                              f6 3a e7 9e f1 22 20  |........`.:..." |
0000b2f0  61 74 20 6c 69 6e 65 20  22 3b 9e 3a e0 8b f1 3a  |at line ";.:...:|
0000b300  e0 0d                                             |.. 2....*H.+H. q|
I tried to extract this with STRINGTERM $b2e9 13 and it almost worked, apart from the double quote characters.
Humm I wonder what the easiest way of dealing with this one is, maybe any string that contains either single or double quotes is broken up into multiple parts, with the quote defined as a seperate EQUB and the string parts as EQUS? That would be more generic as not all assemblers would
support escaping the character.
3. When extracting a table of addresses using:

Code: Select all

word pc 114
it would be nice to have a flag to allow these to be added automatically as code entry points. That would shorten the control file considerable.
try using "wordentry" intead of "word"...... From the documentation :

wordentry addr count
Defines a block of words that will be read and added to the list of entry points.
This is useful for vector tables e.g. the reset, BRK/IRQ and NMI vectors can be added with wordentry $FFFA 3

You have read the documentation :) :) :)
4. More of an observation, but the newer versions of BeebDis does tend to be much more liberal with labels than the older versions. In some cases labels are defined, but never referenced. This makes it harder to spot code that is not obviously reachable.

I think the issue is that everything you add to the control file results in a label, even if that is not intended and there are no references to it.
That could indeed be the case, I'll see about doing some lable pruning, should be reasonably easy to include a count in the symbol definition code so that a symbol is only included in the listing if it is actually refferenced as a jump or data target (or specified entry point).

Thanks for the feedback.

Cheers.

Phill.

User avatar
jgharston
Posts: 4001
Joined: Thu Sep 24, 2009 12:22 pm
Location: Whitby/Sheffield
Contact:

Re: BeebDis updates

Post by jgharston » Sun Apr 22, 2018 6:05 pm

hoglet wrote:Hi Phill,
Thanks for all this work.
I've used BeebDis again in anger over the last few days, doing a disassembly of BBC Basic 4r32:
https://github.com/hoglet67/BBCBasic4r3 ... isassembly
I made a start on Basic 4.32 some time ago. Every now and then I comment a few more lines:
mdfs.net/bbcbasic/bbc.

Code: Select all

$ bbcbasic
PDP11 BBC BASIC IV Version 0.32
(C) Copyright J.G.Harston 1989,2005-2020
>_

Post Reply

Return to “software & utilities for the pc, mac or unix”