summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2017-09-08 00:23:04 +0100
committerDavid Spencer <idlemoor@slackbuilds.org>2017-09-08 00:23:04 +0100
commitccfcfd929245345323d1646c1f191178d362abd5 (patch)
tree3eb490839e3cdefead5bc49bfde0d08d2f255e1e
parent8c0ffd397b35cadfca32308acb17fb137e307f10 (diff)
downloadslackbuilds-ccfcfd929245345323d1646c1f191178d362abd5.tar.gz
development/dis: Added (statically tracing 6502 disassembler).
Signed-off-by: David Spencer <idlemoor@slackbuilds.org>
-rw-r--r--development/dis/20150816.25e17c0f.diff177
-rw-r--r--development/dis/README13
-rw-r--r--development/dis/dis.SlackBuild53
-rw-r--r--development/dis/dis.info10
-rw-r--r--development/dis/slack-desc19
-rw-r--r--development/dis/usr_share.diff13
6 files changed, 285 insertions, 0 deletions
diff --git a/development/dis/20150816.25e17c0f.diff b/development/dis/20150816.25e17c0f.diff
new file mode 100644
index 0000000000..2b64eb40e9
--- /dev/null
+++ b/development/dis/20150816.25e17c0f.diff
@@ -0,0 +1,177 @@
+diff --git a/README.md b/README.md
+index b9e708c..01aa299 100644
+--- a/README.md
++++ b/README.md
+@@ -29,10 +29,13 @@ Usage
+ -comment Emit comments
+ -call Emit callers
+ -access Emit accessors
++ -extern Emit labels for out-of-range addresses
++ -rangelabels Emit labels for ranges instead of base+offset
+ -verbose Print info to STDERR
+ -dump Print options in format for -a
+ -a FILE Read options from FILE. Lines are: OPTION VALUE
+
++ Addresses may include a range, e.g. table=$300+F
+ Addresses may include xex segment number, e.g. 3:1FAE
+
+ Examples
+diff --git a/dis b/dis
+index 13090f4..83a3be2 100755
+--- a/dis
++++ b/dis
+@@ -41,7 +41,7 @@ use constant {
+
+ sub state {
+ return {
+- #mem => [map [0], 0 .. 0x10000],
++ mem => [map [0], 0 .. 0x10000],
+ segnum => 0,
+ };
+ }
+@@ -79,10 +79,10 @@ sub labels {
+ (?:\+([0-9a-fA-F]+))? # optional range in hex
+ /x;
+ $match or die "ERROR: Unrecognized $opt address: $value\n";
+- my $label = $1;
+ my $segnum = $2 || 0;
+ my $base = hex($3);
+ my $range = hex($4||0);
++ my $label = $1 || sprintf "u%2X", $base;
+ for my $off (0 .. $range) {
+ my $addr = $base + $off;
+ if (($addr & 0xFFFF) != $addr) {
+@@ -92,6 +92,7 @@ sub labels {
+ if (defined $state->{$opt}{$segnum}{$addr}) {
+ warn sprintf "WARNING: Duplicate $opt: $value: %X\n",
+ $addr;
++ next;
+ }
+ $state->{$opt}{$segnum}{$addr} =
+ $off ? $rangelabels ? sprintf "${label}_%X", $off :
+@@ -194,14 +195,18 @@ sub trace {
+ my $targ = rel($i, $i1);
+ trace($state, $targ, $byte->[LABEL], $i);
+ } elsif ($mode =~ /Ind|Z-Page/) {
+- my $tlabel = $mem->[$i1][LABEL];
++ my $data = $mem->[$i1];
++ my $pre = $data->[SEGNUM] ? sprintf "s$data->[SEGNUM]" : "";
++ my $tlabel = $data->[LABEL] ||= $pre . sprintf "l%02X", $i1;
+ push @{$byte->[TARGETS]}, $tlabel if $tlabel;
+- push @{$mem->[$i1][ACCESSORS]}, seglabel($state, $i);
++ push @{$data->[ACCESSORS]}, seglabel($state, $i);
+ } elsif ($mode =~ /Absolute/) {
+ my $addr = addr($i1, $i2);
+- my $tlabel = $mem->[$addr][LABEL];
++ my $data = $mem->[$addr];
++ my $pre = $data->[SEGNUM] ? sprintf "s$data->[SEGNUM]" : "";
++ my $tlabel = $data->[LABEL] ||= $pre . sprintf "l%04X", $addr;
+ push @{$byte->[TARGETS]}, $tlabel if $tlabel;
+- push @{$mem->[$addr][ACCESSORS]}, seglabel($state, $i);
++ push @{$data->[ACCESSORS]}, seglabel($state, $i);
+ }
+ $i += $len[$code];
+ }
+@@ -214,23 +219,24 @@ sub extern {
+ return if not $opts->{extern};
+ return if not $opts->{labels};
+ my @labels;
+- for my $opt (qw(code data vector)) {
+- for my $labels (values %{$state->{$opt}||{}}) {
+- for my $addr (sort {$a <=> $b} keys %$labels) {
+- my $label = $labels->{$addr} or next;
+- next if $opts->{labelled}{$label};
+- next if not $opts->{referenced}{$label};
+- next if $label =~ /\+/;
+- my $accessors = $state->{mem}[$addr][ACCESSORS];
+- my $access = "";
+- if ($accessors and $opts->{access}) {
+- $access = "\t\t; " . join " ", "Access:", uniq @$accessors;
+- }
+- push @labels, [$addr,
+- sprintf "$labels->{$addr} equ \$%X$access\n", $addr];
+- }
++ for (my $addr = 0; $addr < 0x10000; ++$addr) {
++ my $label = $state->{mem}[$addr][LABEL] or next;
++ next if $opts->{labelled}{$label};
++ next if not $opts->{referenced}{$label};
++ next if $label =~ /\+/;
++ my $comment = "";
++ my $accessors = $state->{mem}[$addr][ACCESSORS];
++ if ($accessors and $opts->{access}) {
++ $comment .= "\t\t; " . join " ", "Access:", uniq @$accessors;
+ }
++ my $callers = $state->{mem}[$addr][CALLERS];
++ if ($callers and $opts->{call}) {
++ $comment .= "\t\t; " . join " ", "Callers:", uniq @$callers;
++ }
++ push @labels, [$addr,
++ sprintf "$label equ \$%X$comment\n", $addr];
+ }
++ print "##EXTERN##\n";
+ print map $_->[1], sort { $a->[0] <=> $b->[0] } @labels;
+ }
+
+@@ -286,8 +292,6 @@ sub dis {
+ my $targ = $imm8 = $imm16 = $rel = $targets->[-1];
+ $targ =~ s/\+.*//;
+ $opts->{referenced}{$targ}++;
+- # Use z: if label is not predeclared in zero-page
+- $imm8 = "z:$imm8" if not defined $mem->[$i1][VALUE];
+ } elsif ($mode eq "Immediate" and $state->{constant}{$segnum}{$i1}) {
+ $imm8 = $state->{constant}{$segnum}{$i1};
+ $opts->{referenced}{$imm8}++;
+@@ -522,7 +526,7 @@ sub raw {
+ my ($stream, $opts) = @_;
+ my $start = hex($opts->{org}||0);
+ my $end = $start + (length $stream) - 1;
+- printf " opt h-\n";
++ printf " opt h-\n" unless $opts->{headers};
+ printf " org \$%04X\n", $start;
+ my $state = state();
+ layer($state, $start, $end, $stream);
+@@ -616,6 +620,7 @@ sub main {
+ call!
+ access!
+ extern!
++ headers!
+ verbose!
+ dump!
+ arg|a=s@
+@@ -650,6 +655,13 @@ sub main {
+ warn "WARNING: Truncating file at 1M\n";
+ }
+
++ if ($opts{extern} and open my $pipe, "-|") {
++ $_ = do { local $/; <$pipe> };
++ s/(.*)##EXTERN##\n(.*)/$2$1/s;
++ print;
++ exit 0;
++ }
++
+ if ($opts{type} eq "xex") {
+ xex($stream, \%opts);
+ } elsif ($opts{type} eq "prg") {
+diff --git a/sid.dop b/sid.dop
+index 0a85ddf..ea19fab 100644
+--- a/sid.dop
++++ b/sid.dop
+@@ -28,4 +28,4 @@ data SIDPADX=$D419
+ data SIDPADY=$D41A
+ data SIDOSCIL=$D41B
+ data SIDENVEL=$D41C
+-data SID=$D41D+D2
++data SID=$D41D+E2
+diff --git a/sys.dop b/sys.dop
+index 96c7266..a875e15 100644
+--- a/sys.dop
++++ b/sys.dop
+@@ -339,7 +339,7 @@ data COLOR2=$2C6
+ data COLOR3=$2C7
+ data COLOR4=$2C8 ;BACKGROUND
+ ;($2C9 - $2DF SPARE)
+-data GLBABS=$2E0 ;GLOBAL VARIABLES
++data GLBABS=$2E0+2 ;GLOBAL VARIABLES
+ ;($2E0 - $2E3 SPARE)
+ data RAMSIZ=$2E4 ;RAM SIZE (HI BYTE ONLY)
+ data MEMTOP=$2E5+1 ;TOP OF AVAILABLE MEMORY
diff --git a/development/dis/README b/development/dis/README
new file mode 100644
index 0000000000..d287f5b55a
--- /dev/null
+++ b/development/dis/README
@@ -0,0 +1,13 @@
+dis (statically tracing 6502 disassembler)
+
+dis creates XASM/MADS-compatible assembly code from a memory dump or an
+executable. dis statically traces execution paths starting from code
+entry points to mark which memory locations contain code. All other
+memory is treated as data. dis traces through JMP, JSR and BXX branch
+instructions. It stops at RTS, RTI and illegal instructions.
+
+dis automatically determines code entry points when disassembling Atari
+XEX/SAP files and Commodore 64 PRG files.
+
+The .dop files mentioned in the documentation are installed to
+"/usr/share/dis".
diff --git a/development/dis/dis.SlackBuild b/development/dis/dis.SlackBuild
new file mode 100644
index 0000000000..f92b7d2a57
--- /dev/null
+++ b/development/dis/dis.SlackBuild
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# Slackware build script for dis
+
+# Written by B. Watson (yalhcru@gmail.com)
+
+# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
+
+PRGNAM=dis
+VERSION=${VERSION:-0.5_20150816.25e17c0f}
+BUILD=${BUILD:-1}
+TAG=${TAG:-_SBo}
+
+# no compiled code here
+ARCH=noarch
+
+CWD=$(pwd)
+TMP=${TMP:-/tmp/SBo}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
+
+set -e
+
+# my ($release, $commit) = split /_/, $version;
+# Who says perl is less readable than bash?
+RELEASE="$( echo $VERSION | cut -d_ -f1 )"
+COMMIT="$( echo $VERSION | cut -d_ -f2 )"
+
+rm -rf $PKG
+mkdir -p $TMP $PKG $OUTPUT
+cd $TMP
+rm -rf $PRGNAM-$RELEASE
+tar xvf $CWD/$PRGNAM-$RELEASE.tar.gz
+cd $PRGNAM-$RELEASE
+chown -R root:root .
+chmod 644 *
+
+patch -p1 < $CWD/$COMMIT.diff
+patch -p1 < $CWD/usr_share.diff # look for .dop files also in /usr/share/dis
+
+# manual install
+mkdir -p $PKG/usr/bin $PKG/usr/share/$PRGNAM $PKG/usr/doc/$PRGNAM-$VERSION
+install -m0755 $PRGNAM $PKG/usr/bin
+install -m0644 *.dop $PKG/usr/share/$PRGNAM
+install -m0644 *.md $PKG/usr/doc/$PRGNAM-$VERSION
+
+cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
+
+mkdir -p $PKG/install
+cat $CWD/slack-desc > $PKG/install/slack-desc
+
+cd $PKG
+/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
diff --git a/development/dis/dis.info b/development/dis/dis.info
new file mode 100644
index 0000000000..faa6418866
--- /dev/null
+++ b/development/dis/dis.info
@@ -0,0 +1,10 @@
+PRGNAM="dis"
+VERSION="0.5_20150816.25e17c0f"
+HOMEPAGE="https://github.com/lybrown/dis"
+DOWNLOAD="https://github.com/lybrown/dis/archive/v0.5/dis-0.5.tar.gz"
+MD5SUM="2324745bb363dcf7e0cfab830a799e90"
+DOWNLOAD_x86_64=""
+MD5SUM_x86_64=""
+REQUIRES=""
+MAINTAINER="B. Watson"
+EMAIL="yalhcru@gmail.com"
diff --git a/development/dis/slack-desc b/development/dis/slack-desc
new file mode 100644
index 0000000000..8beb4acb2a
--- /dev/null
+++ b/development/dis/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description.
+# Line up the first '|' above the ':' following the base package name, and
+# the '|' on the right side marks the last column you can put a character in.
+# You must make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':' except on otherwise blank lines.
+
+ |-----handy-ruler------------------------------------------------------|
+dis: dis (statically tracing 6502 disassembler)
+dis:
+dis: dis creates XASM/MADS-compatible assembly code from a memory dump or
+dis: an executable. dis statically traces execution paths starting from
+dis: code entry points to mark which memory locations contain code. All
+dis: other memory is treated as data. dis traces through JMP, JSR and BXX
+dis: branch instructions. It stops at RTS, RTI and illegal instructions.
+dis:
+dis: dis automatically determines code entry points when disassembling
+dis: Atari XEX/SAP files and Commodore 64 PRG files.
+dis:
diff --git a/development/dis/usr_share.diff b/development/dis/usr_share.diff
new file mode 100644
index 0000000000..535fcd294e
--- /dev/null
+++ b/development/dis/usr_share.diff
@@ -0,0 +1,13 @@
+diff -Naur dis-0.5/dis dis-0.5.patched/dis
+--- dis-0.5/dis 2017-09-07 16:42:33.595299125 -0400
++++ dis-0.5.patched/dis 2017-09-07 16:42:51.714298161 -0400
+@@ -539,7 +539,8 @@
+ sub arg {
+ my ($opts, $args, $file) = @_;
+ return if grep $file eq $_, $opts->{arg};
+- open my $fh, $file or die "ERROR: Cannot open $file: $!\n";
++ my $fh;
++ open $fh, $file or open $fh, "/usr/share/dis/$file" or die "ERROR: Cannot open $file: $!\n";
+ my %args = map { /(\w+)/; my $a = $1; $a => [/=s/, /@/] } @$args;
+ while (<$fh>) {
+ s/;.*//;