Aug 11, 2018
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.
https://github.com/akkartik/mu/tree/76aace4625/subx
permalink
* *
Aug 4, 2018
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].
https://github.com/akkartik/mu/tree/55b4627de1/subx
[1] Originally in the context of Lisp: https://github.com/akkartik/wart/commit/c2e6d0c6d3
[2] https://www.w3.org/Style/Examples/007/leaders.en.html
permalink
* *
Jul 30, 2018
Factorial on SubX
http://akkartik.name/images/20180730-subx-factorial.html
Ok, I think I understand calling conventions now.
Also coming face to face with the pain of debugging machine code 😀
https://github.com/akkartik/mu/commit/62c6d1638a
permalink
* *
Jul 26, 2018
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".
https://github.com/akkartik/mu/tree/6e51c60c699/subx/Readme.md
permalink
* *
Jul 9, 2018
After playing with the ELF format for a few days, it's starting to sink in that binaries need to specify the location of the data segment, but the locations of the stack and heap are the kernel's prerogative.
Obvious with hindsight.
permalink
* *
Jul 1, 2018
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"):
- <binary>
- `bb 2a 00 00 00`
- `bb 42/imm32` (todo: check that `bb` accepts an imm32)
- `mov_imm 42/imm32` (planned; like Forth, no overloading names)
It'll eventually start getting more high level.
- String literals.
- Function calls.
- ...
permalink
* *