Mar 31, 2019
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.

https://github.com/akkartik/mu/blob/d0d0fdb37/subx/Readme.md

permalink

* *
Mar 16, 2019
I just wrote up something about the way I tend to program: http://akkartik.name/post/four-repos.

A sort of software-centered usesthis.com.

permalink

* *
Jan 11, 2019
In the 12 days since my last update on https://github.com/akkartik/mu/tree/db8a9ab553/subx:
  • 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.

More details: https://github.com/akkartik/mu/tree/db8a9ab553/subx#a-few-hints-for-debugging

permalink

* *
Jan 3, 2019
"We do not influence the course of events by persuading people that we are right when we make what they regard as radical proposals. Rather, we exert influence by keeping options available when something has to be done at a time of crisis." — Milton Friedman

From http://erights.org via https://github.com/darius/squeam

permalink

* *
Dec 31, 2018
Want to get more regular with my status updates here. In the 7 days since my last on https://github.com/akkartik/mu/blob/5a68894ca/subx/Readme.md:

Next up: compiling SubX in SubX. Phase 1 is done: translating text hex bytes into binary http://akkartik.github.io/mu/blob/5a68894ca/subx/apps/hex.subx.html. 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.

permalink

* *
Nov 30, 2018
My assembly language hasn't had much syntax highlighting, and I'm playing with a use for all those colors: 4 types of comments!

It took some doing to make them look ok on my 256-color terminal, but also pass the WCAG contrast checker. (They barely do.) Tell me what you think.

screenshot of a code fragment showing 4 colors of comments

What the different colors signify:
what the different colors signify

https://github.com/akkartik/mu/blob/c6f522007/subx/Readme.md

permalink

* *
Nov 26, 2018
Did you ever try to work through Jack Crenshaw's "Let's build a compiler"? Remember the early point where you add a line of code and "CONGRATULATIONS! You have just written a working compiler!"?

Well, I just ported that one line (and the page of helpers backing it) to my own assembly lang, and it only took me 2 months to do it 😂

In my defense: a) It's *thoroughly* unit-tested asm, and b) I had to rethink the design of a couple of OS syscalls to make them testable.

https://github.com/akkartik/mu/blob/3b6fcde4f/subx/Readme.md

permalink

* *
Oct 2, 2018
'Modules' in machine code

SubX now supports code in multiple files. Segments with the same name get merged.

One subtlety: later code is *prepended* to earlier code. Gives us executable libraries with overrideable entrypoints.

$ git clone https://github.com/akkartik/mu
$ cd mu/subx
$ ./subx translate *.subx -o out
$ ./out  # run tests
$ ./subx translate *.subx apps/factorial.subx -o out
$ ./out;  echo $?
120  # factorial(5)
$ ./out test  # run tests

https://github.com/akkartik/mu/blob/29ab43973a/subx/Readme.md

We also now have the ability to allocate new segments in virtual memory using mmap(). The first new segment I plan on is a 'trace' segment that tests can write to and make assertions on. Automated white-box testing.

Next up, once I have some tracing primitives: a dependency-injected interface for sockets so that we can write automated tests for a fake network.

permalink

* *
Sep 23, 2018
More adventures with machine code

SubX now has a test harness, and support for string literals.

Current (increasingly silly) factorial program to compare with the parent toot: http://akkartik.name/images/20180923-subx-factorial.html

Two new features:

a) Autogenerated `run_tests` (line 26) which calls all functions starting with 'test_'.

b) String literals (line 31). They get transparently moved to the data segment and replaced with their address.

https://github.com/akkartik/mu/blob/37d53a709/subx/Readme.md

There's only one problem: I don't know how to build a compiler. Not really. And definitely not in machine code. So I'm going to be fumbling around for a bit. Lots more wrong turns in my future.

I've been trying to port the Crenshaw compiler to SubX. With tests. It's been slow going, because I have to think about how to make Crenshaw's primitives like Error() and Abort() testable.

I don't know if just learning to build a compiler will sustain my motivation, though. So some other ideas:

a) Some sort of idealized register allocator in Python or something. I've never built one, and my intuitions on how hard it is seem off.

b) Port Mu's fake screen/keyboard to SubX so that I can reimplement https://github.com/akkartik/mu/tree/master/edit#readme. It was just too sluggish since Mu was interpreted. Even my 12-year-old students quickly dropped it in favor of Vim.

permalink

* *
Aug 13, 2018
SubX now supports basic file operation syscalls: https://github.com/akkartik/mu/blob/7328af20a/subx/ex8.subx

I've also made labels a little safer, so you can't call to inside a function, or jump to within a different function: https://github.com/akkartik/mu/blob/7328af20a/subx/037label_types.cc

Next stop: socket syscalls!

https://github.com/akkartik/mu/blob/7328af20a/subx/Readme.md

permalink

* *
archive
projects
writings
videos
subscribe
Mastodon
RSS (?)
twtxt (?)
Station (?)