aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2018-09-10 04:23:12 -0700
committerH. Peter Anvin <hpa@zytor.com>2018-09-10 04:23:12 -0700
commita27c0fff19225acde1ef4e7ee15d40e74b25b45c (patch)
tree631723fefd108c1bf798c5b3bd9875f7c1f9de3b
parentfbb2a47f3580d6481927a201e00de5a263f9d826 (diff)
downloadabc80-a27c0fff19225acde1ef4e7ee15d40e74b25b45c.tar.gz
abc80-a27c0fff19225acde1ef4e7ee15d40e74b25b45c.tar.xz
abc80-a27c0fff19225acde1ef4e7ee15d40e74b25b45c.zip
bin2bac: for ABC800, support reserving memory at BOTM
To install modules on an ABC800, it is common to want to do so at BOTM. This is where BASIC-II stores COMMON variables, so we can easily reserve memory there by setting the size of the COMMON variable area in the header. Then the installer can move BOTM to reserve memory permanently, which can be less than the amount of memory reserved in the header. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--data/bac800.asm13
-rwxr-xr-xdata/bin2bac.pl43
2 files changed, 35 insertions, 21 deletions
diff --git a/data/bac800.asm b/data/bac800.asm
index f2aba8a..57456ba 100644
--- a/data/bac800.asm
+++ b/data/bac800.asm
@@ -21,11 +21,14 @@ _header:
defb 0
defb 21h ; Program flags (meaning unclear)
defb 0
-LEN: defw _end + 7 ; Adjust to total file length (7 = trailer)
- defb 0, 0
- defb 0, 0, 0, 0
- defb 0, 0, 0, 0
- defb 0, 0, 0, 0
+PRGSZ: defw _end + 7 ; Adjust to total file length (7 = trailer)
+ defw 0 ; Scalar variable area size
+ defw 0 ; Address for scalar variable area
+ defw 0 ; Variable count
+COMSZ: defw 0 ; COMMON area size (memory reserved @ BOTM)
+ defw 0 ; COMMON declarations checksum
+ defw 0 ; Address for the first DEF statement
+ defw 0 ; Address for the first DATA statement
;; BASIC bytecode to invoke _start
_basic:
diff --git a/data/bin2bac.pl b/data/bin2bac.pl
index c68d85f..95bf1f9 100755
--- a/data/bin2bac.pl
+++ b/data/bin2bac.pl
@@ -161,8 +161,8 @@ sub makebac80($$$$) {
return $q;
}
-sub makebac800($$$) {
- my($data, $entry, $relocs) = @_;
+sub makebac800($$$$) {
+ my($data, $entry, $relocs, $reserve) = @_;
(undef, $relocs, undef) = pack_relocs($data, $relocs);
# For ABC800 we don't use the adjusted data
@@ -192,7 +192,7 @@ sub makebac800($$$) {
# See bac800.asm
$bhdr = "\x8f\x00\x21\x00";
$bhdr .= pack("v", 0x5a + length($relocs) + length($data));
- $bhdr .= ("\0" x 14);
+ $bhdr .= pack("v*", 0, 0, 0, $reserve, 0, 0, 0);
$bhdr .= "\xe8\xd1\x19\xfa\x9c\xd1\x17\xb8\x92";
$bhdr .= "\x01" . pack("v", 0xffca - length($relocs));
$bhdr .= "\x7d\x91\x4f\x7c\x98\x47\xb1\x28\x25\xe5\x11\x34\x00";
@@ -213,7 +213,18 @@ sub makebac800($$$) {
return $data;
}
+sub intval($) {
+ my($s) = @_;
+
+ $s =~ s/[\s_]//g;
+
+ return 0 if ($s eq '');
+ return undef if ($s !~ /^(0[0-7]*|0x[0-9a-f]+|[0-9]+)$/i);
+ return ($s =~ /^0/) ? oct $s : $s+0;
+}
+
my $abc800 = 0;
+my $reserve = 0;
while ($ARGV[0] =~ /^-/) {
my $opt = shift;
@@ -221,25 +232,27 @@ while ($ARGV[0] =~ /^-/) {
$abc000 = 0;
} elsif ($opt eq '-800') {
$abc800 = 1;
+ } elsif ($opt eq '-reserve') {
+ $reserve = intval(shift);
+ } else {
+ die "$0: Unknown option: $opt\n";
}
}
($file, $org, $entry, $entryname) = @ARGV;
if (!defined($file)) {
- die "Usage: $0 [-80|-800] inputfile {load_addr|relocfile}\n".
- " [entrypoint|deffile [entryname]]\n";
+ die "Usage: $0 [-80|-800] [-reserve bytes]\n".
+ " inputfile {load_addr|relocfile} [entrypoint|deffile [entryname]]\n";
}
-if ($org !~ /^[0-9]/) {
- $relocfile = $org;
- undef $org;
-} else {
- $org = oct $org if ( $org =~ /^0/ );
-}
+my $relocfile = $org;
+$org = intval($org);
+undef $relocfile if (defined($org));
-if ($entry !~ /^[\s0-9x]*$/) {
- $entryfile = $entry;
+my $entryfile = $entry;
+$entry = intval($entry);
+if (!defined($entry)) {
$entryname = '_start' unless(defined($entryname));
undef $entry;
@@ -257,8 +270,6 @@ if ($entry !~ /^[\s0-9x]*$/) {
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";
@@ -278,7 +289,7 @@ if (defined($relocfile)) {
}
if ($abc800) {
- print makebac800($dd, $entry, $relocs);
+ print makebac800($dd, $entry, $relocs, $reserve);
} else {
print makebac80($dd, $org, $entry, $relocs);
}