mu/shell/README.md

82 lines
2.9 KiB
Markdown
Raw Normal View History

2021-03-09 04:57:11 +00:00
### A prototype shell for the Mu computer
2021-06-15 20:02:10 +00:00
Currently runs a tiny dialect of Lisp. Steps to run it from the top-level:
2021-03-09 04:57:11 +00:00
1. Build it:
2021-06-15 21:46:27 +00:00
```sh
$ ./translate shell/*.mu # generates code.img
```
2021-06-15 21:48:52 +00:00
You can now already run it (under emulation):
2021-06-15 21:46:27 +00:00
```sh
$ qemu-system-i386 code.img
```
2021-06-15 21:46:27 +00:00
But let's add some more 'meat' to play with.
2021-06-15 20:02:10 +00:00
2. Create a data disk with a library of functions.
2021-04-24 04:36:48 +00:00
2021-06-15 21:46:27 +00:00
```sh
$ dd if=/dev/zero of=data.img count=20160
$ cat shell/data.limg |dd of=data.img conv=notrunc
```
2021-04-24 04:36:48 +00:00
2021-06-15 21:46:27 +00:00
Run with data disk (and 2GB of RAM):
```sh
$ qemu-system-i386 -m 2G -hda code.img -hdb data.img
```
2021-03-09 05:03:15 +00:00
2021-06-15 22:54:56 +00:00
<img alt='screenshot of the Mu shell' src='../html/20210615-shell.png'>
2021-06-15 21:48:52 +00:00
The Mu computer has a fixed-size screen, which the shell environment
partitions into two major regions, with a context-sensitive menu of keyboard
shortcuts along the bottom. (No mouse support at the moment.) On the left,
two-thirds of the screen is for editing functions and viewing documentation
on available primitives. On the right is a REPL where you can try out
expressions and see their output. The REPL also has a little toy screen and
keyboard for interactively playing with side effects of expressions.
Try typing in some expressions at the REPL and hitting `ctrl-s` to see their
results. Hit `ctrl-m` to focus on the `...` after a run, and browse how the
_trace_ of how the results were computed. [Here's a 2-minute demo](https://archive.org/details/akkartik-mu-2021-05-31).
2021-04-24 04:49:28 +00:00
2021-06-15 20:02:10 +00:00
3. If your Qemu installation supports them, one of these commandline arguments
may speed up emulation:
2021-04-24 04:49:28 +00:00
2021-06-15 21:46:27 +00:00
- `-enable-kvm`
- `-accel ___` (run with `-accel help` for a list of available options)
2021-04-24 04:49:28 +00:00
2021-06-15 21:46:27 +00:00
If you do this, I recommend also adjusting the `responsiveness` mask in
shell/evaluate.mu, which controls how frequently the fake screen updates.
Smaller values will seem more responsive, larger values will leave more time
to run your programs. I like to see the screen update about once a second.
Some suggested values depending on how fast your Qemu is running:
2021-06-15 20:02:10 +00:00
2021-06-15 21:46:27 +00:00
- `-enable-kvm` on a T420s running Linux: `0xffff/responsiveness=64k`
- `-accel tcg` on a 2019 Mac: `0xfff/responsiveness=4k`
2021-06-15 20:02:10 +00:00
2021-06-15 21:46:27 +00:00
Putting it all together, here's the command I typically use on Linux:
2021-04-24 04:49:28 +00:00
2021-06-15 21:46:27 +00:00
```
$ qemu-system-i386 -m 2G -enable-kvm -hda code.img -hdb data.img
```
2021-04-24 04:49:28 +00:00
2021-03-09 05:03:15 +00:00
*Known issues*
2021-06-15 20:02:10 +00:00
* No mouse support.
2021-03-09 05:03:15 +00:00
* Don't press keys too quickly (such as by holding down a key). The Mu
computer will crash (and often Qemu will segfault).
2021-04-25 23:02:30 +00:00
2021-06-15 20:02:10 +00:00
* Mu currently assumes access to 2GB of RAM. To increase that, modify the
2021-04-25 23:02:30 +00:00
definition of `Heap` in 120allocate.subx, and then modify the `-m 2G`
argument in the Qemu commands above. Mu currently has no virtual
memory. If your Heap is too large for RAM, allocating past the end of RAM
will succeed. However, accessing addresses not backed by RAM will fail with
this error:
```
lookup: failed
```