Commit Graph

5485 Commits

Author SHA1 Message Date
Kartik Agaram 6d79c2bbf6 5435 - redo 5426
We can now translate layers 49-55 using translate and ntranslate. Next
step is to support '\n' in dquotes.subx.
2019-07-21 01:09:51 -07:00
Kartik Agaram 22a9035e82 5434 2019-07-21 00:25:00 -07:00
Kartik Agaram 709e895514 5433 2019-07-21 00:17:37 -07:00
Kartik Agaram bcb5f18fc1 5432 2019-07-21 00:08:13 -07:00
Kartik Agaram 90538f232a 5431 - starting to translate std lib
Currently failing at layer 54:
```
$ time ./translate 049memory_layout.subx 05[0-4]*.subx;  ./subx run a.elf test
leaky-get-or-insert-slice: too many segments
```

Emulation is also damn slow. But running in native mode is fast.
2019-07-20 23:59:23 -07:00
Kartik Agaram 4fe73d4757 5430 - all examples passing
We now have a new pass called 'tests' which code-generates a new
function called 'run-tests', just like the C++ layer `tests.cc`.
2019-07-20 23:38:11 -07:00
Kartik Agaram f6b8bcb307 5429
Fix CI.
2019-07-20 22:32:53 -07:00
Kartik Agaram a84b759f23 5428 2019-07-20 21:35:43 -07:00
Kartik Agaram 83b7c4a101 5427 2019-07-20 21:26:15 -07:00
Kartik Agaram 47a9d22a05 5426 2019-07-20 09:48:57 -07:00
Kartik Agaram c37b575a04 5425 2019-07-20 00:09:21 -07:00
Kartik Agaram 3af52436df 5424 2019-07-19 23:45:04 -07:00
Kartik Agaram 66159de90b 5423 2019-07-19 23:41:36 -07:00
Kartik Agaram 88cbe04d7e 5422
Various buffer sizes needed to be grown for ex11. But the next
bottleneck is that we need to code-generate run-tests.
2019-07-19 23:30:33 -07:00
Kartik Agaram c086f1bec7 5421 2019-07-19 21:25:17 -07:00
Kartik Agaram a03bbc827d 5420 2019-07-19 11:38:57 -07:00
Kartik Agaram 31cb01daf4 5419
Bugfix fourteen: we need different address computation logic for code vs
data labels.

It's really about different categories of instructions having different
address computation logic. This subtle distinction will make good error
messages hard. But that's a problem for later.

Now there's just one example program not translating.
2019-07-19 11:29:52 -07:00
Kartik Agaram cfb4b738c6 5418 - vim tweaks
When running a single test, stop always opening the trace. Instead create
a separate affordance for that, and also have it reuse windows.
2019-07-19 10:30:23 -07:00
Kartik Agaram 3943b27a00 5417
Clean up.
2019-07-18 23:29:36 -07:00
Kartik Agaram 8da4c8c300 5416
Figured out what's going in with bug fourteen: displacement operands
aren't always used relative to the PC. Does this mean I need to track
instruction boundaries past pack? :'(

No, I just need different logic for labels in code vs data segments.

This was an interesting bug for reminding me of the difference between
the emulator-level trace and the application-level trace. The former has
1.5 million lines, while the latter has a dozen. Luckily, just dumping
the latter immediately made obvious what the issue was.

Though this experience does suggest some further ideas for debugging
tools:

  slice trace by line and phase
    slice trace by start and end label

  debug UI for SubX translator
    2D layout: rows = lines of code;  columns = translator phases
    each 'cell' in this layout contains a list of log lines
    shows what came in, what was emitted
    easily collapse any cell

These are domain-specific tools. Special-cased to the SubX translator
phases.
2019-07-18 23:24:49 -07:00
Kartik Agaram 5030d67c85 5415
Bugfix thirteen: displacement calculations were wrong because current
offset was not being updated properly as words were being read and
emitted.

Now 10/12 example programs are translated correctly.
2019-07-17 23:04:45 -07:00
Kartik Agaram 7fe1e24349 5414 2019-07-17 22:56:18 -07:00
Kartik Agaram 2a13be5fd7 5413
Bugfix twelve: ModR/M was being incorrectly computed.

This is one of two problems with subx/examples/ex3, so no new passing
examples.
2019-07-17 19:11:26 -07:00
Kartik Agaram 22bb33eb47 5412
Fix CI.
2019-07-17 08:46:50 -07:00
Kartik Agaram 2bceaa4a26 5411
Fix CI.
2019-07-17 07:31:47 -07:00
Kartik Agaram 294a152063 5410 - 4 examples passing
Clean up other examples as well to satisfy the requirements in commit
5404.
2019-07-17 00:47:11 -07:00
Kartik Agaram 4d37fb5213 5409
Bugfix eleven: segment flags were incorrectly computed. examples/ex1 now
verified! Added to CI.
2019-07-17 00:29:52 -07:00
Kartik Agaram c2a74205d6 5408
Bugfix ten: type error in `convert`. I was calling `rewind-stream` on a
`buffered-file`.

examples/ex1 is now just one nibble off the canonical.

I *have* found one missing feature in the self-hosted translator,
though: dquotes doesn't support newlines in strings, even though the C++
version does. dquotes parses them right, but the value initialized in
the data segment is wrong.
2019-07-16 23:40:25 -07:00
Kartik Agaram 70a999aaeb 5407
Bugfix nine: flush(out) after translation is done.

Still one remaining bug from comparing ELF binaries: emit-segments
prints nothing for some reason.
2019-07-15 17:03:39 -07:00
Kartik Agaram 5490993845 5406
Bugfix eight: incorrect segment count in ELF header.

The generated examples/ex1 is still not right. But it has the second
segment now. Or almost all of it. Final byte is missing for some reason.
2019-07-15 16:39:13 -07:00
Kartik Agaram 9ad8133197 5405 2019-07-15 15:47:35 -07:00
Kartik Agaram aef4efb959 5404 - subx/examples/ex1 now translating
The result isn't an identical binary to before, and it segfaults when
run. But it's bugfix seven.

A couple of places where we make .subx files a little more strict:

a) All .subx files must define a data segment. Even if they have no
data.

b) All .subx files must define an `Entry` label for the binary to start
at. Earlier we used to default to the start of the code label. That's
not too hard to add; we'd just need to:
  i) rename `get` to `get-or-abort`
  ii) clone a third variant of `get-or-insert` called `get` that returns
     null if the key is not found.
  iii) use `get` rather than `get-or-abort` when looking up the `Entry`
     label.
2019-07-15 12:26:41 -07:00
Kartik Agaram 867894b3ef 5403 2019-07-14 15:00:55 -07:00
Kartik Agaram 670d945763 update roadmap in subx/Readme 2019-07-14 14:24:35 -07:00
Kartik Agaram ce2c1efc41 . 2019-07-14 09:42:36 -07:00
Kartik Agaram c4412d299e . 2019-07-13 22:35:15 -07:00
Kartik Agaram c4aa819a5d
Merge pull request #34 from akkartik/survey
SubX in SubX: computing addresses for labels
2019-07-13 19:50:49 -07:00
Kartik Agaram 7f23be0107 .
Clean up.
2019-07-13 19:49:55 -07:00
Kartik Agaram ae30c4682c add subx/apps/survey to CI 2019-07-13 19:47:23 -07:00
Kartik Agaram e63ec16b9f . 2019-07-13 19:44:52 -07:00
Kartik Agaram 2773d5a48a survey.subx now passing all tests 2019-07-13 19:41:16 -07:00
Kartik Agaram 17fb42cfd9 grow the output stream; test now completes
All assertions in `test-convert-computes-addresses` still failing.
2019-07-13 19:36:53 -07:00
Kartik Agaram c6f91e15a4 `test-convert-computes-addresses` bugfix six
map of how far we've gotten by now (functions with '*' independently tested):
✓ compute-offsets*
✓ compute-addresses*
✓ emit-output
✓   emit-headers
✓     emit-elf-header
✓       emit-hex-array*
✓     first emit-elf-program-header-entry
✓       emit-hex-array*
?     second emit-elf-program-header-entry
        emit-hex-array*
    emit-segments*
2019-07-13 19:25:52 -07:00
Kartik Agaram 62bb910301 . 2019-07-13 15:48:11 -07:00
Kartik Agaram 58c643c2c2 fixed fifth bug, hit sixth 2019-07-13 15:43:32 -07:00
Kartik Agaram d30c716db2 .
Clean up.
2019-07-13 15:40:25 -07:00
Kartik Agaram 50ac5cab9c fixed fourth bug, hit fifth 2019-07-13 15:18:00 -07:00
Kartik Agaram 195a0d7d7d fixed third bug, hit fourth 2019-07-13 14:47:03 -07:00
Kartik Agaram 4c81119344 .
Clean up.
2019-07-13 12:30:38 -07:00
Kartik Agaram a2593892de fixed second bug, hit third 2019-07-13 12:27:54 -07:00