aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2018-04-24 18:57:21 -0700
committerH. Peter Anvin <hpa@zytor.com>2018-04-24 18:57:21 -0700
commitaceee818e04e859b6f0a6647cc329295dc68f278 (patch)
tree0ff34bd3df3dc5b1ca6fefd1ed380f82ba7308d7
parent5ffd585ed26277f93db37112b239e55f70b3f26b (diff)
downloadabc80-aceee818e04e859b6f0a6647cc329295dc68f278.tar.gz
abc80-aceee818e04e859b6f0a6647cc329295dc68f278.tar.xz
abc80-aceee818e04e859b6f0a6647cc329295dc68f278.zip
bin2bac: don't create variables, use STOP rather than END
Use PRINT instead of Z%= so we don't create any variables on the heap. The PRINT never actually executes so that is OK. Terminate with STOP rather than END. If this ever executes, something is seriously wrong so an error message is appropriate.
-rwxr-xr-xdata/bin2bac.pl15
1 files changed, 9 insertions, 6 deletions
diff --git a/data/bin2bac.pl b/data/bin2bac.pl
index 65673a4..17b68a9 100755
--- a/data/bin2bac.pl
+++ b/data/bin2bac.pl
@@ -116,12 +116,15 @@ sub makebac($$$$) {
my $r = 0; # Last emitted line number
# Address 65054 is EOFA
- # 1 Z%=CALL(PEEK(65054%)+SWAP%(PEEK(65055%))-<loader offset>)
+ # 1 PRINT CALL(PEEK(65054%)+SWAP%(PEEK(65055%))-<loader offset>)
+ # Use PRINT here rather than the traditional Z%=, because that
+ # way we don't create any variables on the heap. As a side benefit,
+ # it is actually shorter. Since the CALL() never returns, it will
+ # never actually print anything anyway.
$q .= bacstmt(++$r, \$left,
- "\x83\xc1\xf1\x5a\x00\xbb\xc7\x1e\xfe\xce\x36\xc7".
- "\x1f\xfe\xce\x36\xce\x34\xf5\xc7".
+ "\x84\xc7\x1e\xfe\xce\x36\xc7\x1f\xfe\xce\x34\xf5\xc7".
pack("v", length($bld)+2). # +2 for statement trailer
- "\xf8\xce\x3a\xb7");
+ "\xf8\xce\x3a\xba");
my $i = 0;
my $dl = length($data);
@@ -148,8 +151,8 @@ sub makebac($$$$) {
$addr += $l;
}
- # Terminal END statement
- $q .= bacstmt(++$r, \$left, "\x86\x8a"); # END
+ # Terminal STOP statement (should obviously never execute)
+ $q .= bacstmt(++$r, \$left, "\x86\x89"); # STOP
# Loader code (string expression)
$q .= bacstmt(++$r, \$left, "\xcb\"".pack("C",length($bld)).$bld."\xbb");