Sep 6, 2019
Update on the Mu computer

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

Version 0 without any syntax sugar takes up 50 lines and 180 columns for factorial and one unit test.

Version 1 with syntax sugar for addressing modes takes up 50 lines and 40 columns.

Version 2 with syntax sugar for addressing modes _and_ function calls takes up just 28 lines and 40 columns.

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.

https://github.com/akkartik/mu#readme

permalink

* *
Sep 3, 2019
How SubX code has evolved over the past year

2018/Jul/30

2019/Sep/03

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.

Screenshot of a terminal pipeline generating the longest lines of code in https://github.com/akkartik/mu/blob/904a053e9c3b55079ea842eb0c4447e0b8cb1022/apps/calls.subx

permalink

* *
Sep 2, 2019
Update on the Mu computer

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

Expansion for a single Subx function call in s-expression format.

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
Uses the just-created addressing mode notation!

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

permalink

* *
Aug 31, 2019
More deletions later, LoC in my fork of the Linux kernel are down from 27.1M to 12.3M. Goal is to only support lowest-common-denominator devices.

https://github.com/akkartik/mu#readme

(My line-counting was way off earlier.)

permalink

* *
Aug 30, 2019
Reason #83 to fork the Linux Kernel

I get to see my name and picture on a git log alongside Linus Torvalds's.

https://github.com/akkartik/kernel#readme

permalink

* *
Aug 25, 2019
Update on the Mu computer

Now that we have a bootstrapped (quasi-) language and (kinda) bootstrapped OS, we're finally starting to think about less error-prone notations.

This week two of us built a notation for x86 addressing modes:

  • direct: %ecx
  • indirect: *ecx
  • indirect with displacement: *(ecx+4)
  • indirect with index, scale and displacement: *(ecx + edx<<3 + 4)

Not yet sure this is a good approach. But it'll be fun to playtest.

Here's before and after screenshots for factorial.subx.

Before:

Tabular program in my syntax for machine code requires 160-character lines.

After:

Same program with some syntax sugar fits mostly in 40-character lines.

(project link)

permalink

* *
Aug 20, 2019
Now that I have the beginnings of a whole new computer, I'm at a loss for what to work on next. (One of the items is H's suggestion of socket syscalls.)

Today's little mini-experiment: a program to print out random numbers in an infinite loop. Works fine on Linux or Mac, but only prints zeroes when packaged up with my kernel fork and run on Qemu or Linode. Looks like I need to do something to initialize /dev/random.

(More details)

Here's my complete current list of ideas, just for triggering serendipity:

  • Test /dev/random without my kernel changes
  • Test framebuffer syscalls
  • Client socket helpers
  • A compiled language -- kinda like my previous prototype (https://github.com/akkartik/mu1#readme)
  • Some sort of storage. Either ramdisk (volatile) or local disk (needs mount) or S3 (needs sockets)
  • An interpreted language. Either a subset of Oil or a straight-up Lisp. Needs storage.

permalink

* *
Aug 19, 2019
Updated Mu's fork of the Linux kernel again. Today I deleted the entire top-level sound/ directory and a whole bunch of unused file systems.

LoC down from 6.1M to 4.4M.

Context: https://github.com/akkartik/mu#readme

permalink

* *
Aug 14, 2019
Stack manipulations in SubX

I've been noodling on a Forth-inspired (but likely insane) syntactic sugar for stack manipulations in raw machine code. Behold:

{ 0 0 ->%ecx
...
}

This expands to:

push 0/imm32
push 0/imm32
copy %esp to %ecx
...
add 8 to %esp

Basically you get a (fairly unsafe) block scope containing an 8-byte local in %ecx.

To temporarily spill a register:

{ %ecx
...
}

Function call:

{ z y x
call f/disp32
}

The `}` turns into code to undo pushes in the `{` line.

permalink

* *
Aug 11, 2019
Now that I'm packaging Mu with a fork of bleeding-edge Linux, I have a tiger by the tail. I need to stay abreast of changes from upstream or risk bitrot, particularly as new security vulnerabilities are uncovered and patched.

I'm going to start changing the kernel soon, and I need a way to not kill myself merging patches from upstream. For starters: aggressively delete code Mu doesn't need. That'll reduce merge conflicts.

In the first run I just deleted non-x86 architectures. So far so good.

permalink

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