Want to get more regular with my status updates here. In the 7 days since my last on github.com/akkartik/mu/tree/ma:

- a simple memory allocator, assuming we rarely free: akkartik.github.io/mu/html/sub

- a sketch of safe pointers for a later compiler of a C-like language: akkartik.github.io/mu/html/sub

- compiled a fairly small Linux kernel and ran SubX with it on Qemu. Still need to get it booting a real laptop and VPS. Also, /dev/fb0.

- light background for my terminals! And for the above code renderings.

Next up: compiling SubX in SubX. Phase 1 is done: translating text hex bytes into binary akkartik.github.io/mu/html/sub. 1700 lines, but sub 200 lines/instructions excluding tests and comments.

Phase 2: packing operand bitfields into bytes.

Phase 3: translating labels. *That* will be interesting, without a hash table for strings.

Show thread

In the 12 days since my last update on github.com/akkartik/mu/tree/ma:

- finished 6/10 primitives for completing phase 2 of the compiler. (Once phase 2 is done I'll be able to compile label-free SubX programs to ELF without needing C.) 2.3k lines, almost 2k of them tests or comments.

- a super elegant workflow for debugging SubX programs. SubX doesn't need an interactive debugger; its trace-based debugging support takes 55 LoC: akkartik.github.io/mu/html/sub

More details: github.com/akkartik/mu/tree/ma

Show thread

My new Assembly syntax is making progress towards being self-hosted. It can now create ELF binaries with data, opcodes and immediate/displacement operands. What's left:

a) Packing mod/reg/rm operands and scale/index/base operands into single bytes. (ETA: 2 days)

b) Handling string literals. (ETA: 1 week)

c) Support for labels. (ETA: ???. 3 months, if past history is any guide.)

Then: Goodbye C! Goodbye dependencies I don't understand! Hello, *true* collaboration.

github.com/akkartik/mu/blob/ma

Show thread

My new Assembly syntax is now 4/5ths bootstrapped in itself. Just one phase left: github.com/akkartik/mu/pull/34

The previous phase took 7 weeks, but what's a factor of 7 between friends 😄

Some LoC stats (total, and excluding comments/tests):

hex: 1511/144
pack: 7348/1054
assort: 1318/284
dquotes: 2694/497

Similarly, some executable sizes:

hex: 22KB/3KB
pack: 37KB/8KB
assort: 22KB/5KB
dquotes: 27KB/6KB

github.com/akkartik/mu/blob/ma

/cc @rain @vertigo @kragen

Show thread

*Status update on self-hosting my new Assembly syntax*

All tests for the fifth and final phase are written, and detailed pseudocode has been sketched out (in classic waterfall fashion): github.com/akkartik/mu/blob/b5. That seems like 90% done. Is this when they say the remaining 90% kicks in? 🙂

(More info: github.com/akkartik/mu/blob/ma)

@rain @vertigo @kragen

Show thread

*Status update on self-hosting my new Assembly syntax*

All phases are done and passing tests separately. However I haven't yet managed to actually put the final phase together with the rest to build any actual programs.

Here's what I have so far in the final phase: akkartik.github.io/mu/html/sub

I've also started working on the next step: a simple list of steps for building a minimal Linux kernel to go with SubX. It's the final dependency.

See more: github.com/akkartik/mu/blob/ma

@rain @vertigo @kragen

Show thread

*Status update on self-hosting my new Assembly syntax*

First example program successfully translated!

4 programs now translating:

✓ ex1
✓ ex2
ex3
✓ ex4
ex5
ex6
✓ ex7
ex8
ex9
...

Sample run:

$ cat examples/ex1.subx |dquotes |assort |pack |survey |hex > a.elf

github.com/akkartik/mu/blob/ma

@rain @vertigo @kragen

Show thread

*Status update on self-hosting my new Assembly syntax*

2 bugfixes later, 10/12 example programs building correctly.

There's one known hole in my implementation: it doesn't support '\n' in string literals. Now may be the time to plug this gap.

github.com/akkartik/mu/blob/ma

@rain @vertigo @kragen

Show thread

*Status update on self-hosting my new Assembly syntax*

Another day, another bug fixed, another example program working.

But now I've hit a missing feature: code-generating the special `run-tests` function, which just calls all functions starting with 'test-'. Pretty much all remaining programs are now bottlenecked on this.

Next few tasks:

- run-tests
- '\n' in string literals
- it's dog slow. Probably the linear search. But no profiling yet.

github.com/akkartik/mu/blob/ma

@rain @vertigo @kragen

Show thread

*Status update on self-hosting my new Assembly syntax*

Test harness done. The self-hosted translator now handles all 12 example programs. A beach-head for reproducible builds.

Time to start translating the standard library. In emulated mode things get slow *fast*:

$ time ./translate 049*.subx 05[0-n]*.subx
35 lines in 9s
84 lines in 20s
219 lines in 59s
262 lines in 68s
382 lines in ... ERROR

In native mode, translating 262 lines takes 0.1s.

github.com/akkartik/mu/blob/ma

@rain @vertigo @kragen

Show thread

*Status update on self-hosting my new Assembly syntax*

Standard library is now self-hosted!

apps/factorial is also translating successfully, and the binary is the exact same size as before. However there are diffs to track down.

I'm ignoring emulated mode for now, and am testing ELF binaries natively. 5k lines of input take 26 seconds to translate. The cost: having to slum it with some light debug by print action in the absence of time-travel debugging.

@rain @vertigo @kragen

Show thread

*Status update on self-hosting my new Assembly syntax*

All example apps now translating correctly, and the result is bit-for-bit identical with the results of the C++ translator.

The last remaining step, the final frontier: SubX-in-SubX in SubX-in-SubX. Translating the self-hosted translator using the self-hosted translator. Still seeing some discrepancies there.

I fixed just one bug since yesterday, but had to cope with a 4.4GB trace for it.

github.com/akkartik/mu/blob/ma

@rain @vertigo @kragen

Show thread

My new Assembly syntax:
github.com/akkartik/mu/blob/ma

SubX can now build itself! 9kLoC in 1.5s. Caveats:

1. Zero error checking. You still need the C++ translator for development (just like a text editor and other tools).

2. Some programs compile with the C++ translator but not the self-hosted one. Ones with no `Entry` labels, no `data` segments, or with uppercase hex will throw errors. However, it's a bug if a program successfully compiles but generates a different binary.

@rain @vertigo @kragen

· · Web · 2 · 3 · 4
Sign in to participate in the conversation
Mastodon

Server run by the main developers of the project 🐘 It is not focused on any particular niche interest - everyone is welcome as long as you follow our code of conduct!