mu/subx
Kartik Agaram e1fcc521be 4349 2018-07-15 22:29:01 -07:00
..
teensy 4323 2018-07-07 13:54:16 -07:00
000organization.cc 4344 2018-07-15 09:15:45 -07:00
001help.cc 4289 - beginnings of a translator to ELF 2018-06-30 09:41:22 -07:00
002test.cc 4288 2018-06-28 22:03:48 -07:00
003trace.cc 4033 2017-10-12 17:00:48 -07:00
003trace.test.cc 3930 - experimental bytecode interpreter 2017-06-19 21:47:07 -07:00
010core.cc 4342 2018-07-11 07:45:45 -07:00
012direct_addressing.cc 4347 2018-07-15 15:13:31 -07:00
013indirect_addressing.cc 4347 2018-07-15 15:13:31 -07:00
014immediate_addressing.cc 4347 2018-07-15 15:13:31 -07:00
015index_addressing.cc 4347 2018-07-15 15:13:31 -07:00
016jump_relative.cc 4347 2018-07-15 15:13:31 -07:00
017jump_relative.cc 4347 2018-07-15 15:13:31 -07:00
018functions.cc 4347 2018-07-15 15:13:31 -07:00
019syscalls.cc 4333 2018-07-10 07:14:07 -07:00
020elf.cc 4334 2018-07-10 07:18:36 -07:00
021translate.cc 4343 2018-07-14 10:43:34 -07:00
022transform_immediate.cc 4338 - preliminary support for data segments 2018-07-10 20:27:21 -07:00
Readme.md 4348 2018-07-15 15:21:51 -07:00
build 4288 2018-06-28 22:03:48 -07:00
build_and_test_until 4335 2018-07-10 20:18:11 -07:00
cheatsheet.pdf 4026 2017-10-12 09:36:55 -07:00
clean 4314 2018-07-06 22:50:30 -07:00
edit 4323 2018-07-07 13:54:16 -07:00
ex1 4343 2018-07-14 10:43:34 -07:00
ex1.1.subx 4325 2018-07-07 23:13:25 -07:00
ex1.2.subx 4325 2018-07-07 23:13:25 -07:00
ex2 4343 2018-07-14 10:43:34 -07:00
ex2.subx 4325 2018-07-07 23:13:25 -07:00
ex3 4343 2018-07-14 10:43:34 -07:00
ex3.subx 4325 2018-07-07 23:13:25 -07:00
ex4 4343 2018-07-14 10:43:34 -07:00
ex4.subx 4330 - start allocating data/stack/heap segments 2018-07-08 22:57:50 -07:00
g 4321 2018-07-07 10:57:56 -07:00
gen 4321 2018-07-07 10:57:56 -07:00
gg 4321 2018-07-07 10:57:56 -07:00
ggdiff 4349 2018-07-15 22:29:01 -07:00
nrun 4321 2018-07-07 10:57:56 -07:00
opcodes 3968 2017-07-11 21:41:15 -07:00
run 4323 2018-07-07 13:54:16 -07:00
subx 4211 2018-02-20 01:38:15 -08:00
subx.vim 4299 2018-06-30 23:05:10 -07:00
test_layers 4024 - attempt to get CI working for SubX 2017-10-11 03:22:13 -07:00
vimrc.vim 4020 2017-10-11 02:32:38 -07:00
xdiff 4349 2018-07-15 22:29:01 -07:00

Readme.md

What is this?

A suite of tools for directly programming in (32-bit x86) machine code without a compiler. The generated ELF binaries require just a Unix-like kernel to run. (It isn't self-hosted yet, so generating the binaries requires a C compiler and libc.)

Why in the world?

  1. It seems wrong-headed that our computers look polished but are plagued by foundational problems of security and reliability. I'd like to learn to walk before I try to run, use the computer only to check my program for errors and not hide low-level details. That may simplify the hard problems. It adds to the burden of the programmer, but computers have been failing to relieve the programmer entirely. Our abstractions so far leak at inopportune times.

  2. The software in our computers has grown incomprehensible. Nobody understands it all, not even experts. Even simple programs written by a single author require lots of time for others to comprehend. Compilers are a prime example, growing so complex that programmers have to choose to either program them or use them. I'd like to explore how much of a HLL I can build without an optimizing compiler, and see if the result is more comprehensible by others. (More details.)

  3. I want to learn about the internals of the infrastructure we all rely on in our lives.

Running

$ git clone https://github.com/akkartik/mu
$ cd mu/subx
$ ./subx

Running subx will transparently compile it as necessary.

Usage

subx currently has the following sub-commands:

  • subx test: runs all automated tests.

  • subx translate <input file> <output ELF binary>: translates a text file containing hex bytes and macros into an executable ELF binary.

  • subx run <ELF binary>: simulates running the ELF binaries emitted by subx translate. Useful for debugging, and also enables more thorough testing of translate.

I'm not building general infrastructure here for all of the x86 ISA and ELF format. SubX is about programming with a small, regular subset of 32-bit x86:

  • Only instructions that operate on the 32-bit E*X registers. (No floating-point yet.)
  • Only instructions that assume a flat address space; no instructions that use segment registers.
  • No instructions that check the carry or parity flags; arithmetic operations always operate on signed integers (while bitwise operations always operate on unsigned integers)
  • Only relative jump instructions (with 8-bit or 16-bit offsets).

Resources

Inspirations