Commit Graph

4947 Commits

Author SHA1 Message Date
Kartik Agaram 6607a30415 4980 2019-02-18 20:31:44 -08:00
Kartik Agaram dfbc5a6c4b 4979 2019-02-18 20:25:37 -08:00
Kartik Agaram ead24155ca 4978 - maybe we need another phase
Phase 1: coalesce different instances/fragments for each segment, correctly
prepending later fragments.

Phase 2: pack bitfields into bytes.

Phase 3: compute addresses for labels, compute the ELF header.

Phase 4: convert hex bytes to binary.

But ugh, phase 1 involves linked lists and I'll have to go down a rabbit
hole building up more standard library functions.
2019-02-17 07:39:20 -08:00
Kartik Agaram a6079569cc 4977 2019-02-16 23:59:46 -08:00
Kartik Agaram de2990880a 4976 - recommend that operand order be fixed
I've been allowing operands in any order just because it simplifies implementation.
I don't actually rely on this flexibility; all the .subx programs in this
repo consistently use a single ordering.

Why is a hard-coded canonical order hard to implement? The order that seems
most logical to me is complicated by the "reg" bits in the ModR/M byte:

- In instructions that interpret it as an `/r32` operand, it needs to be
  deemphasized because it refers to a different argument of the instruction
  than the `/mod`, `/rm32`, `/base`, `/index` and `/scale` operands that
  capture the bulk of instruction decoding complexity and so should be
  emphasized. `/r32` can also be unused, which strengthens the case for
  deemphasizing it.

- In instructions that interpret the "reg" bits as a `/subop` operand,
  it should be colocated with the opcode because it performs the same function:
  specifying the *operation* the instruction performs.

In both cases, the bits in the `reg` bitfield are conceptually unrelated
to the other bitfields in the same byte. But they sometimes want to be
close to the opcode bytes on the left, and at other times need to be deemphasized
rightward. Fixing both these possibilities seems complicated and stateful,
particularly since all operands are optional in general. On the other hand,
just pulling operands you need to create each byte, regardless of where
in the instruction they occur, that's nicely stateless.
2019-02-16 22:55:12 -08:00
Kartik Agaram bf1fe33c36 4975 - new plan for Phase 2
So far I've been assuming that I'd just statelessly convert each line in
a .subx file. But over the past week or so of constant interruptions I
gradually realized that code and data need different parsers.
2019-02-16 22:36:21 -08:00
Kartik Agaram 1c80a50634 4974
Fix CI.
2019-02-15 17:25:46 -08:00
Kartik Agaram 9b16f19049 4973
Support immediate operands in the data segment in all the ways we support
them in the code segment.
2019-02-15 17:20:57 -08:00
Kartik Agaram 5522bc9ec5 4972 2019-02-15 16:26:14 -08:00
Kartik Agaram 445843f277 4971 - clean up a few scripts
Some of them are no longer useful; drop them.

For the rest, have useful usage messages. And also be a little more principled
in where we introduce CFLAGS, and where we expect it to come in from the
commandline.

I'm choosing not to call gen/run/dgen/drun from test_layers because it
makes test_layers harder for newcomers to read. The scripts aren't the
first thing people should see, they're just useful once you're up and running
hacking on SubX.
2019-02-15 15:48:16 -08:00
Kartik Agaram 2dc9b6955b 4970 2019-02-15 10:13:57 -08:00
Kartik Agaram 6ded65f45f 4969 2019-02-15 00:01:51 -08:00
Kartik Agaram 554777cb2b 4968 2019-02-14 23:57:14 -08:00
Kartik Agaram 9309600c5a 4967 2019-02-14 23:00:47 -08:00
Kartik Agaram db2be4dd83 4966
Standardize how we show register allocation decisions.
2019-02-14 22:58:18 -08:00
Kartik Agaram db268970a9 4965 2019-02-14 22:46:07 -08:00
Kartik Agaram 1076cc4cf9 4964 2019-02-14 18:42:21 -08:00
Kartik Agaram 833152354e 4963 2019-02-14 16:49:10 -08:00
Kartik Agaram 1e43ba2b74 4962
Build the C++ version optimized by default when building/running all apps.
We have enough apps now that the cost of optimized builds is worthwhile.
2019-02-14 16:29:52 -08:00
Kartik Agaram 1639687ba0 4961 2019-02-14 16:24:20 -08:00
Kartik Agaram 1ab48a69cc 4960
I think I don't need to special-case packing for different segments. That
should massively cut down on the number of tests.
2019-02-13 11:28:21 -08:00
Kartik Agaram a630d7fb96 4959
It's always seemed ugly to explain the rules for segment names. Let's just
always require a fixed name for the code and data segments.
2019-02-13 00:01:14 -08:00
Kartik Agaram ac73f9caf3 4958 - all my apps fit in 4KB so far
(excluding tests)
2019-02-11 23:38:17 -08:00
Kartik Agaram 7bc0f8c1d0 4957 2019-02-11 23:01:20 -08:00
Kartik Agaram 0527fd92cb 4956 2019-02-11 22:58:25 -08:00
Kartik Agaram a06dee4fcd 4955
Starting to build up Phase 2 (apps/pack) out of recently designed primitives.
2019-02-10 17:14:15 -08:00
Kartik Agaram 38ef68b269 4954 2019-02-10 16:54:20 -08:00
Kartik Agaram 6e181e7fd9 4953 2019-02-05 23:30:12 -08:00
Kartik Agaram f070557859 4952 2019-02-05 23:29:15 -08:00
Kartik Agaram ddd2e9891e 4951
Cleaner way to compare streams in tests.
2019-02-03 23:33:48 -08:00
Kartik Agaram 51b4f888dd 4950 2019-02-03 23:29:46 -08:00
Kartik Agaram 03c6f1d385 4949 2019-02-02 22:05:11 -08:00
Kartik Agaram cb82bd2364 4948
This seems like the final helper we need for Phase 2. Now to build the
business logic itself.
2019-02-02 15:21:48 -08:00
Kartik Agaram 4cb7d1fb77 4947
Bugfix: has-metadata? was corrupting registers

Seems uneconomic to write tests for stuff like this. Assembly is just not
the right layer to try to come up with a general solution or process. Keep
running your code and wait to find signs of breakage.
2019-02-01 23:52:36 -08:00
Kartik Agaram 77aa333c3c 4946 2019-02-01 23:51:58 -08:00
Kartik Agaram 0ad068dd1d 4945 2019-02-01 23:49:41 -08:00
Kartik Agaram 070659f917 4944
Improve syntax highlighting in the Readme.
2019-01-30 10:16:33 -08:00
Kartik Agaram 44bb71e7de 4943 2019-01-30 10:08:47 -08:00
Kartik Agaram 95540b2452 4942 2019-01-21 00:59:05 -08:00
Kartik Agaram f5fce35ebf 4941 2019-01-21 00:58:45 -08:00
Kartik Agaram ee2f7013c3 4940 2019-01-21 00:48:42 -08:00
Kartik Agaram 148ab0a23e 4939 2019-01-21 00:00:00 -08:00
Kartik Agaram c65dee2d99 4938 2019-01-20 23:20:34 -08:00
Kartik Agaram 332cbba31f 4937 2019-01-20 22:50:44 -08:00
Kartik Agaram 1f0f381303 4936 2019-01-18 22:30:38 -08:00
Kartik Agaram 305770aabc 4935 2019-01-16 11:17:07 -08:00
Kartik Agaram 0c11cafe79 4934 2019-01-16 11:16:34 -08:00
Kartik Agaram 71ee78f279 4933 2019-01-16 11:13:39 -08:00
Kartik Agaram 76733e1995 4932 2019-01-16 00:12:55 -08:00
Kartik Agaram 05cffaa69f 4931 2019-01-16 00:11:41 -08:00