about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2021-08-29 11:25:08 -0700
committerKartik K. Agaram <vc@akkartik.com>2021-08-29 11:25:08 -0700
commitbd226ccb3ad94e3196ac10a0e70734293a38e52c (patch)
treee4401db29430cae4b27afb918bed75ce05f54fe8
parentefae02cf1120fa58a64affadbfc4966ad0835c4d (diff)
downloadmu-bd226ccb3ad94e3196ac10a0e70734293a38e52c.tar.gz
improve translation scripts
-rwxr-xr-xtranslate23
-rwxr-xr-xtranslate_emulated23
2 files changed, 38 insertions, 8 deletions
diff --git a/translate b/translate
index 22b299bd..e0e3ba02 100755
--- a/translate
+++ b/translate
@@ -3,6 +3,15 @@
 
 set -e
 
+# Map of the Mu code disk
+export DISK=20160  # 20*16*63 512-byte sectors = almost 10MB
+dd if=/dev/zero of=code.img count=$DISK
+# code: sectors 0-10079
+# debug: sector 10080 onwards
+export DEBUG=10080
+
+## Code
+
 cat $* [0-9]*.mu                                          |linux/mu                         > a.subx
 
 cat boot.subx font.subx mu-init.subx [0-9]*.subx a.subx   |linux/braces                     > a.braces
@@ -24,8 +33,6 @@ cat a.pack                                                |linux/labels_baremeta
 
 cat a.survey                                              |linux/hex                        > a.bin
 
-# Create code.img containing a.bin
-dd if=/dev/zero of=code.img count=20160  # 20*16*63 512-byte sectors = almost 10MB
 dd if=a.bin of=code.img conv=notrunc
 
 if [ `stat --printf="%s" a.bin` -ge 492544 ]  # 15 tracks * 63 sectors per track * 512 bytes per sector (keep this sync'd with boot.subx)
@@ -40,8 +47,14 @@ then
   exit 1
 fi
 
-# Latter half of disk is for debug info.
-dd if=labels of=code.img seek=10080 conv=notrunc  # keep this sync'd with abort.subx
+if [ `stat --printf="%s" a.bin` -ge $(($DEBUG*512)) ]
+then
+  echo "a.bin will overwrite debug info on disk"
+  exit 1
+fi
+
+## Latter half of disk is for debug info
+
 if [ `stat --printf="%s" labels` -ge 1048576 ]  # 8 reads * 256 sectors * 512 bytes per sector
 then
   echo "labels won't all be loaded on abort"
@@ -53,3 +66,5 @@ then
   echo "abort will go into infinite regress"
   exit 1
 fi
+
+dd if=labels of=code.img seek=$DEBUG conv=notrunc  # keep this sync'd with abort.subx
diff --git a/translate_emulated b/translate_emulated
index 1093c3ba..6d3b6681 100755
--- a/translate_emulated
+++ b/translate_emulated
@@ -7,6 +7,15 @@
 set -e
 set -v
 
+# Map of the Mu code disk
+export DISK=20160  # 20*16*63 512-byte sectors = almost 10MB
+dd if=/dev/zero of=code.img count=$DISK
+# code: sectors 0-10079
+# debug: sector 10080 onwards
+export DEBUG=10080
+
+## Code
+
 cat $* [0-9]*.mu                                          |linux/bootstrap/bootstrap run linux/mu                         > a.subx
 
 cat boot.subx font.subx mu-init.subx [0-9]*.subx a.subx   |linux/bootstrap/bootstrap run linux/braces                     > a.braces
@@ -28,8 +37,6 @@ cat a.pack                                                |linux/bootstrap/boots
 
 cat a.survey                                              |linux/bootstrap/bootstrap run linux/hex                        > a.bin
 
-# Create code.img containing a.bin
-dd if=/dev/zero of=code.img count=20160  # 20*16*63 512-byte sectors = almost 10MB
 dd if=a.bin of=code.img conv=notrunc
 
 if [ `stat --printf="%s" a.bin` -ge 492544 ]  # 15 tracks * 63 sectors per track * 512 bytes per sector (keep this sync'd with boot.subx)
@@ -44,8 +51,14 @@ then
   exit 1
 fi
 
-# Latter half of disk is for debug info.
-dd if=labels of=code.img seek=10080 conv=notrunc  # keep this sync'd with abort.subx
+if [ `stat --printf="%s" a.bin` -ge $(($DEBUG*512)) ]
+then
+  echo "a.bin will overwrite debug info on disk"
+  exit 1
+fi
+
+## Latter half of disk is for debug info
+
 if [ `stat --printf="%s" labels` -ge 1048576 ]  # 8 reads * 256 sectors * 512 bytes per sector
 then
   echo "labels won't all be loaded on abort"
@@ -57,3 +70,5 @@ then
   echo "abort will go into infinite regress"
   exit 1
 fi
+
+dd if=labels of=code.img seek=$DEBUG conv=notrunc  # keep this sync'd with abort.subx