mu/linux
Kartik K. Agaram 791a71e27e fix a long-standing bug in Mu's translator
While all test pass, this change is disquieting. When I first designed
Mu I deliberately chose to exclude literal strings from most primitive
instructions both for type-checking and to avoid silently passing
through strange constructions. Nobody really needs to add a string to a
number, and am I sure no SubX instruction will cause a memory safety
issue when passed a string literal instead of a number?

But clearly I have no tests encoding this desire. And any string literal
could be replaced by an integer literal containing the exact same value,
so what are we protecting against anyway.

Let me fix the bug for now. If I run into problems I'll come back and do
this right.
2021-08-22 22:10:02 -07:00
..
apps . 2021-07-20 08:43:25 -07:00
bootstrap . 2021-07-16 08:28:56 -07:00
browse 7846 2021-03-04 00:11:23 -08:00
tile . 2021-03-29 18:47:52 -07:00
000init.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
100.txt . 2021-03-29 18:47:52 -07:00
101_write.subx start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
102test.subx start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
103kernel-string-equal.subx start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
104new-segment.subx start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
105string-equal.subx start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
106stream.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
107trace.subx . 2021-07-20 08:43:25 -07:00
108write.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
109stream-equal.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
110stop.subx . 2021-07-20 08:43:25 -07:00
111read.subx . 2021-07-20 08:43:25 -07:00
112read-byte.subx . 2021-07-20 08:43:25 -07:00
113write-stream.subx . 2021-07-20 08:43:25 -07:00
114error.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
115write-byte.subx . 2021-07-20 08:43:25 -07:00
116write-buffered.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
117write-int-hex.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
118parse-hex-int.subx . 2021-07-20 08:43:25 -07:00
119error-byte.subx . 2021-07-20 08:43:25 -07:00
120allocate.subx start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
121new-stream.subx . 2021-07-20 08:43:25 -07:00
122read-line.subx . 2021-07-20 08:43:25 -07:00
123slice.subx . 2021-07-20 08:43:25 -07:00
124next-token.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
125write-stream-data.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
126write-int-decimal.subx . 2021-07-20 08:43:25 -07:00
127next-word.subx support non-line-oriented processing in next-word 2021-07-29 20:07:13 -07:00
128subx-words.subx 7867 2021-03-07 21:05:45 -08:00
129emit-hex.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
130emit.subx 7867 2021-03-07 21:05:45 -08:00
131table.subx start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
132slurp.subx . 2021-07-20 08:43:25 -07:00
133subx-widths.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
134emit-hex-array.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
135next-word-or-string.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
200.txt . 2021-03-29 18:47:52 -07:00
201register-names.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
202write-int.subx . 2021-07-20 08:43:25 -07:00
203stack.subx . 2021-07-20 08:43:25 -07:00
300.txt 7842 - new directory organization 2021-03-03 22:21:03 -08:00
301array-equal.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
302stack_allocate.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
303kernel-string.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
304screen.subx . 2021-05-14 23:15:46 -07:00
305keyboard.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
306files.subx . 2021-05-14 07:59:32 -07:00
307size.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
308allocate-array.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
309stream.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
310copy-bytes.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
311decimal-int.subx . 2021-05-14 23:15:46 -07:00
312copy.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
313index-bounds-check.subx always check for null in 'index' instructions 2021-05-07 21:04:45 -07:00
314divide.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
315slice.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
400.mu 7867 2021-03-07 21:05:45 -08:00
401test.mu update vocabulary documentation 2021-03-08 23:50:35 -08:00
402time.mu 7842 - new directory organization 2021-03-03 22:21:03 -08:00
403unicode.mu 7846 2021-03-04 00:11:23 -08:00
404stream.mu update vocabulary documentation 2021-03-08 23:50:35 -08:00
405screen.mu 7842 - new directory organization 2021-03-03 22:21:03 -08:00
406int32.mu 7842 - new directory organization 2021-03-03 22:21:03 -08:00
407right-justify.mu 7842 - new directory organization 2021-03-03 22:21:03 -08:00
408float.mu 7842 - new directory organization 2021-03-03 22:21:03 -08:00
409print-float-hex.mu 7842 - new directory organization 2021-03-03 22:21:03 -08:00
410file.mu 7842 - new directory organization 2021-03-03 22:21:03 -08:00
411string.mu 7842 - new directory organization 2021-03-03 22:21:03 -08:00
412print-float-decimal.mu update vocabulary documentation 2021-03-08 23:50:35 -08:00
README.md . 2021-07-16 08:28:56 -07:00
assort start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
assort.subx . 2021-07-20 08:43:25 -07:00
braces start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
braces.subx . 2021-07-20 08:43:25 -07:00
branches.mu support checking overflow flag everywhere 2021-05-08 21:49:50 -07:00
branches.out support checking overflow flag everywhere 2021-05-08 21:49:50 -07:00
calls start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
calls.subx . 2021-07-20 08:43:25 -07:00
dquotes start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
dquotes.subx . 2021-07-20 08:43:25 -07:00
help make online help more obvious 2021-04-04 20:12:43 -07:00
hex start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
hex.subx . 2021-07-20 08:43:25 -07:00
labels_baremetal start throwing error on labels too far for /disp8 2021-08-22 21:40:03 -07:00
labels_baremetal.subx start throwing error on labels too far for /disp8 2021-08-22 21:40:03 -07:00
mu fix a long-standing bug in Mu's translator 2021-08-22 22:10:02 -07:00
mu-init-test.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
mu-init.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
mu.subx fix a long-standing bug in Mu's translator 2021-08-22 22:10:02 -07:00
pack start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
pack.subx . 2021-07-20 08:43:25 -07:00
sigils start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
sigils.subx . 2021-07-20 08:43:25 -07:00
stack_array.subx . 2021-03-24 09:12:32 -07:00
stats.txt . 2021-03-29 18:47:52 -07:00
subx-params.subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
subx_debugging.md 7847 2021-03-04 00:24:24 -08:00
survey_baremetal start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
survey_baremetal.subx start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
survey_elf start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
survey_elf.subx start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
test_apps start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
test_apps_emulated . 2021-07-20 08:43:25 -07:00
tests start throwing error on duplicate label 2021-08-22 21:09:28 -07:00
tests.subx . 2021-07-20 08:43:25 -07:00
translate 7842 - new directory organization 2021-03-03 22:21:03 -08:00
translate_debug 7842 - new directory organization 2021-03-03 22:21:03 -08:00
translate_emulated 7842 - new directory organization 2021-03-03 22:21:03 -08:00
translate_subx 7842 - new directory organization 2021-03-03 22:21:03 -08:00
translate_subx_debug 7842 - new directory organization 2021-03-03 22:21:03 -08:00
translate_subx_emulated 7842 - new directory organization 2021-03-03 22:21:03 -08:00
vocabulary.md . 2021-07-16 09:24:02 -07:00
x86_approx.md . 2021-03-26 22:22:54 -07:00

README.md

This directory contains Mu programs and infrastructure that require a Linux kernel. To run programs under this directory, you must first cd into it.

$ cd linux/
$ ./translate apps/hello.mu      # generates a.elf
$ ./a.elf
Hello world!

See the shared vocabulary of data types and functions shared by Mu programs running on Linux. Mu programs can transparently call low-level functions written in SubX.

Some programs to try out:

  • tile: An experimental live-updating postfix shell environment that updates as you type. Prototype. Look at this to see what is currently possible, not how I recommend building software.

    tile app
  • browse: A text-mode browser for a tiny subset of Markdown.

  • apps/ex*: small stand-alone examples that don't need any of the shared code at the top-level. They each have a simple pedagogical goal. Read these first.

  • apps/factorial*: A simple program to compute factorials in 5 versions, showing all the different syntax sugars and what they expand to.

The Mu compiler toolchain is also here in the following phases:

  • Bare SubX: hex, survey_elf, pack, dquotes, assort, tests
  • Syntax sugar for SubX: sigils, calls, braces
  • Mu->SubX compiler: mu. Compiles most statements to a single instruction of machine code.

The toolchain includes binaries in the repo. At any commit, the binary should be identical bit for bit with the result of translating the corresponding .subx file. The binary should also be natively runnable on a Linux system running on Intel x86 processors, either 32- or 64-bit. If either of these invariants is violated, it's a bug.