about summary refs log tree commit diff stats
path: root/shell
diff options
context:
space:
mode:
Diffstat (limited to 'shell')
-rw-r--r--shell/README.md17
-rw-r--r--shell/main.mu20
2 files changed, 36 insertions, 1 deletions
diff --git a/shell/README.md b/shell/README.md
index 7a6600c2..463f8e16 100644
--- a/shell/README.md
+++ b/shell/README.md
@@ -1,9 +1,24 @@
 ### A prototype shell for the Mu computer
 
-Currently runs a tiny subset of Lisp. To build and run it from the top-level:
+Currently runs a tiny subset of Lisp. Steps to run it from the top-level:
 
+1. Build it:
 ```sh
 $ ./translate shell/*.mu      # generates disk.img
+```
+
+2. Create a data disk:
+```sh
+$ dd if=/dev/zero of=data.img count=20160
+```
+
+3. Optionally load an s-expression into the disk:
+```sh
+$ echo '(+ 1 1)' |dd of=data.img conv=notrunc
+```
+
+4. Run it:
+```sh
 $ qemu-system-i386 disk.img
 ```
 
diff --git a/shell/main.mu b/shell/main.mu
index eb437b67..38683293 100644
--- a/shell/main.mu
+++ b/shell/main.mu
@@ -5,6 +5,7 @@ fn main {
   var sandbox-storage: sandbox
   var sandbox/esi: (addr sandbox) <- address sandbox-storage
   initialize-sandbox sandbox
+  load-sandbox-from-secondary-disk sandbox
   var width/eax: int <- copy 0
   var height/ecx: int <- copy 0
   width, height <- screen-size 0/screen
@@ -20,3 +21,22 @@ fn main {
     loop
   }
 }
+
+# Read a null-terminated sequence of keys from secondary disk and load them
+# into sandbox.
+fn load-sandbox-from-secondary-disk _self: (addr sandbox) {
+  var self/esi: (addr sandbox) <- copy _self
+  var s-storage: (stream byte 0x200)
+  var s/ebx: (addr stream byte) <- address s-storage
+  load-sector-string-from-primary-bus-secondary-drive 0/lbalo, 0/lbamid, 0/lbahi, s
+  {
+    var done?/eax: boolean <- stream-empty? s
+    compare done?, 0/false
+    break-if-!=
+    var key/eax: byte <- read-byte s
+    compare key, 0/null
+    break-if-=
+    edit-sandbox self, key
+    loop
+  }
+}