*Update on the Mu computer's memory-safe language*

Still no type-checking or memory-safety, but we can now write any programs with int variables.

There's still no 'var' keyword, so we can't define local variables yet. But that's not insurmountable; just pass in extra arguments for any space you want on the stack 😀

result <- factorial n 0 0 0

*Update on the Mu computer*

We now have structured control flow (with goto statements 😂 )

Compare this screenshot with the ones in the previous message of this thread.

At this point I think I've climbed as far up the ladder of abstractions as I can with just syntax sugar. The next step up will be a new language. It'll still look the same: registers, curly braces, one operation to a line. But operations won't be x86 opcodes anymore. Registers and operands will have types.

@rain @vertigo

*Update on the Mu computer*

Syntax sugar for function calls is done. Here's factorial with no sugar, addressing modes and function calls, respectively.

Time now to start building a proper language, to occupy C's niche on this new stack. Type-safe, memory-safe, manual (but safe) memory management, manual (but safe) register allocation.

Though I might build a toy Lisp first. I figure I've earned some fun. Seeing a computer boot into a REPL would qualify.


@rain @vertigo

How SubX code has evolved over the past year

2018/Jul/30: mastodon.social/@akkartik/1004

2019/Sep/03: akkartik.name/images/20190903-

The first thing that pops out is that lines have gotten narrower.

Or have they? Scroll down and some long lines start to show up. Even if you ignore trailing comments. Check out the screenshot. Lines wider than 80 characters translate to 2-byte jump instructions. I wonder if I've lost my sense of proportion somewhere along the way.

@rain @vertigo

*Update on the Mu computer*

Now that we have a notation for addressing modes, we're designing syntax for function calls.

It's easiest to parse if we start with a paren and avoid commas. However, the similarity to s-expressions is only skin deep. There can only be 2 levels of parens, and args can't do arbitrary arithmetic.

Pseudocode: akkartik.github.io/mu/html/app
Uses the just-created addressing mode notation! (mastodon.social/@akkartik/1026)

More info: github.com/akkartik/mu#readme

@rain @vertigo

Reason #83 to fork open-source projects

You get to see your name and picture on a git log alongside luminaries like Linus Torvalds.


Cloud VPS from "scratch"

I just successfully built a minimal Linux kernel, installed a SubX binary[1] as init -- and ran the whole thing on a Linode.

It's not in github.com/akkartik/mu yet, but there will soon be step-by-step instructions.

This couldn't have happened without the education I received from minimal.linux-bg.org

[1] github.com/akkartik/mu/blob/4e

2yo just made his first program.

"Giraffe." "Ok, tell me what blocks to use, and I'll make you a giraffe."

There were only a couple of syntax errors. "You already have an eye. Do you want another?"

In the end the project ran out of budget and requirements shifted.

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.


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.


Now that it can translate labels to offsets, SubX also warns on explicit use of error-prone raw offsets. Both when running and in Vim.

As I build up the ladder of abstractions I want to pull up the ladder behind me:

a) Unsafe programs will always work.
b) But unsafe programs will always emit warnings.

As long as SubX programs are always distributed in source form, it will be easy to check for unsafe code. Coming soon: type- and bounds-checking.


@freakazoid @h @rain1@nulled.red

It's been a slow week, but one idea I've been playing with is "comment tokens"[1]: effect-less words that you can sprinkle into your programs to make them more readable.

Concretely, SubX lines can get long, and the comment at the end is often far away and hard to line up visually with the instruction it's referring to. The solution: dot leaders[2].


@h @freakazoid @vertigo

[1] Originally in the context of Lisp: github.com/akkartik/wart/commi

[2] w3.org/Style/Examples/007/lead

Adventures in machine code #3

I just spent a couple of days separating out bitfields in my programs, and writing a translator to pack them correctly.

Then I realized that doing so makes it harder to count bytes when computing jump targets.

Luckily there's just two such bytes in the 32-bit x86 encoding, and most of the time the rule becomes, "add 1 byte if these three columns contain anything".


@h @jjg @vertigo @freakazoid

Lately I've been programming in raw (32-bit x86) machine code, evolving some minimal tooling for error checking rather than information hiding. A few different ways to write the same instruction ("mov ebx, 42"):

1. <binary>
2. `bb 2a 00 00 00`
3. `bb 42/imm32` (todo: check that `bb` accepts an imm32)
4. `mov_imm 42/imm32` (planned; like Forth, no overloading names)

It'll eventually start getting more high level.
5. String literals.
6. Function calls.
7. ...

@h @vertigo

Show more

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!