summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2016-10-14 06:52:37 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2016-10-14 06:52:37 (GMT)
commit2ae02d9256b66756da4b089b65b9f45069baea9d (patch)
treeef503d3222a98b65161dc4663705aa777596752f
parent411d345192ee0c14a57334c01b2638586b0bcad9 (diff)
parentb7e845c0ef0e4dcd8a117ac701e81b568b493217 (diff)
downloadabc80-2ae02d9256b66756da4b089b65b9f45069baea9d.zip
abc80-2ae02d9256b66756da4b089b65b9f45069baea9d.tar.gz
abc80-2ae02d9256b66756da4b089b65b9f45069baea9d.tar.bz2
abc80-2ae02d9256b66756da4b089b65b9f45069baea9d.tar.xz
Merge branch 'de1' of ssh://terminus.zytor.com/pub/git/fpga/abc80/abc80 into de1
-rw-r--r--data/bacldrr.asm4
-rwxr-xr-xdata/bin2bac.pl49
2 files changed, 41 insertions, 12 deletions
diff --git a/data/bacldrr.asm b/data/bacldrr.asm
index 0944c0e..0d8cc46 100644
--- a/data/bacldrr.asm
+++ b/data/bacldrr.asm
@@ -46,8 +46,8 @@ reloc:
reloc_loop:
ld a,(de)
inc de
- cp 7fh ; JR doesn't support testing the sign bit
- jr c,reloc_large
+ cp 80h ; JR doesn't support testing the sign bit
+ jr nc,reloc_large
ld c,a
ld b,0
diff --git a/data/bin2bac.pl b/data/bin2bac.pl
index 0d00c7c..edc67bd 100755
--- a/data/bin2bac.pl
+++ b/data/bin2bac.pl
@@ -91,22 +91,22 @@ sub makebac($$$$) {
$entrypt = 0 unless(defined($entrypt));
# Raw data length, must be recorded before pack_relocs()
- my $data_len = = length($data);
+ my $data_len = length($data);
my $relptr;
($data, $relptr) = pack_relocs($data, $relocs);
$bld = "\x01\xc9\x00\xc5\x2a\x1c\xfe\xe5\x5d\x54\x4e\x09";
- $bld .= "\x7e\xd6\x08\x38\x0a\x0e\x06\x09\x4f\xed\x80";
+ $bld .= "\x7e\xd6\x08\x38\x0a\x0e\x06\x09\x4f\xed\xb0";
$bld .= "\x23\x23\x18\xf1\x21";
# 16-bit length of data not including relocations
$bld .= pack('v', $data_len);
- $bld .= "\xd1\x19\xeb\x1a\x13\xfe\x7f\x38\x0e\x4f\x06\x00";
+ $bld .= "\xd1\x19\xeb\x1a\x13\xfe\x80\x30\x0e\x4f\x06\x00";
$bld .= "\x09\x7d\x86\x77\x7c\x23\x8e\x77\x23\x18\xec";
$bld .= "\xd6\x81\x38\x06\x47\x1a\x13\x4f\x18\xeb\x01";
# 16-bit offset from final relocation to entry point
$bld .= pack('v', $entrypt - $relptr);
- $bld[2] = "\x09\xe9";
+ $bld .= "\x09\xe9";
}
my $q = "\x82"; # Output (program start marker)
@@ -118,7 +118,7 @@ sub makebac($$$$) {
$q .= bacstmt(++$r, \$left,
"\x83\xc1\xf1\x5a\x00\xbb\xc7\x1e\xfe\xce\x36\xc7".
"\x1f\xfe\xce\x36\xce\x34\xf5\xc7".
- pack("v", length($bld)).
+ pack("v", length($bld)+2). # +2 for statement trailer
"\xf8\xce\x3a\xb7");
my $i = 0;
@@ -156,17 +156,46 @@ sub makebac($$$$) {
return $q;
}
-($file, $org, $entry, $relocfile) = @ARGV;
+($file, $org, $entry, $entryname) = @ARGV;
-$org = oct $org if ( $org =~ /^0/ );
-$entry = oct $entry if ( $entry =~ /^0/ );
+if (!defined($file)) {
+ die "Usage: $0 inputfile {load_addr|relocfile} [entrypoint|deffile [entryname]]\n";
+}
+
+if ($org !~ /^[0-9]/) {
+ $relocfile = $org;
+ undef $org;
+} else {
+ $org = oct $org if ( $org =~ /^0/ );
+}
+
+if ($entry !~ /^[0-9]/) {
+ $entryfile = $entry;
+ $entryname = '_start' unless(defined($entryname));
+ undef $entry;
+
+ open(DEF, '<', $entryfile) or die "$0: $entryfile: $!\n";
+ while ($line = <DEF>) {
+ chomp $line;
+ @l = split(/\s+/, $line);
+ if ($l[0] =~ /^DEFC$/i && $l[1] eq $entryname && $l[2] eq '=' &&
+ $l[3] =~ /^\$([0-9a-f]+)$/i) {
+ $entry = hex $1;
+ last;
+ }
+ }
+ close(DEF);
+ if (!defined($entry)) {
+ die "$0: symbol $entryname not found in file $entryfile\n";
+ }
+} else {
+ $entry = oct $entry if ( $entry =~ /^0/ );
+}
open(FILE, '<:raw', $file) or die "$0: $file: $!\n";
read(FILE, $dd, 65536);
close(FILE);
-undef $org if ($org =~ /^(bofa|reloc|\-)$/i);
-
if (defined($relocfile)) {
if (defined($org)) {
die "$0: cannot specify load address and relocation file both\n";