Commit Graph

36 Commits

Author SHA1 Message Date
Kartik Agaram 82fb58e606 CF needs special handling for some arithmetic ops
Inline some macro definitions.
2019-05-12 22:43:31 -07:00
Kartik Agaram 9be1aa30d8 5015 2019-03-22 21:27:32 -07:00
Kartik Agaram 4a943d4ed3 5001 - drop the :(scenario) DSL
I've been saying for a while[1][2][3] that adding extra abstractions makes
things harder for newcomers, and adding new notations doubly so. And then
I notice this DSL in my own backyard. Makes me feel like a hypocrite.

[1] https://news.ycombinator.com/item?id=13565743#13570092
[2] https://lobste.rs/s/to8wpr/configuration_files_are_canary_warning
[3] https://lobste.rs/s/mdmcdi/little_languages_by_jon_bentley_1986#c_3miuf2

The implementation of the DSL was also highly hacky:

a) It was happening in the tangle/ tool, but was utterly unrelated to tangling
layers.

b) There were several persnickety constraints on the different kinds of
lines and the specific order they were expected in. I kept finding bugs
where the translator would silently do the wrong thing. Or the error messages
sucked, and readers may be stuck looking at the generated code to figure
out what happened. Fixing error messages would require a lot more code,
which is one of my arguments against DSLs in the first place: they may
be easy to implement, but they're hard to design to go with the grain of
the underlying platform. They require lots of iteration. Is that effort
worth prioritizing in this project?

On the other hand, the DSL did make at least some readers' life easier,
the ones who weren't immediately put off by having to learn a strange syntax.
There were fewer quotes to parse, fewer backslash escapes.

Anyway, since there are also people who dislike having to put up with strange
syntaxes, we'll call that consideration a wash and tear this DSL out.

---

This commit was sheer drudgery. Hopefully it won't need to be redone with
a new DSL because I grow sick of backslashes.
2019-03-12 19:14:12 -07:00
Kartik Agaram c442a5ad80 4987 - support `browse_trace` tool in SubX
I've extracted it into a separate binary, independent of my Mu prototype.

I also cleaned up my tracing layer to be a little nicer. Major improvements:

- Realized that incremental tracing really ought to be the default.
  And to minimize printing traces to screen.

- Finally figured out how to combine layers and call stack frames in a
  single dimension of depth. The answer: optimize for the experience of
  `browse_trace`. Instructions occupy a range of depths based on their call
  stack frame, and minor details of an instruction lie one level deeper
  in each case.

Other than that, I spent some time adjusting levels everywhere to make
`browse_trace` useful.
2019-02-25 01:50:53 -08:00
Kartik Agaram 8188bbbc94 4981 - no, go back to 3 phases
Considering how much trouble a merge phase would be (commit 4978), it seems
simpler to just add the extra syntax for controlling the entry point of
the generated ELF binary.

But I wouldn't have noticed this if I hadn't taken the time to write out
the commit messages of 4976 and 4978.

Even if we happened to already have linked list primitives built, this
may still be a good idea considering that I'm saving quite a lot of code
in duplicated entrypoints.
2019-02-18 21:48:19 -08:00
Kartik Agaram b6fdd2e4e5 4717 2018-10-24 00:01:00 -07:00
Kartik Agaram 5d06fe27fb 4696
Update the syntax documentation.
2018-10-14 00:13:41 -07:00
Kartik Agaram 0f851e48aa 4695 2018-10-14 00:00:39 -07:00
Kartik Agaram 06d9b1a541 4694
Check for duplicate docstrings.
2018-10-13 23:55:07 -07:00
Kartik Agaram dc559a00c7 4693
Add the standard mnemonic for each opcode.

We aren't ever going to have complete docs of the subset of the x86 ISA
we support, so we need to help readers cross-correlate with the complete
docs.
2018-10-13 23:50:10 -07:00
Kartik Agaram 116e7730d7 4692 - update online help for subx
It now includes details for 8-bit registers. And we'll just use the classic
names for the registers so that the relationships between 8- and 32-bit
versions are more obvious.
2018-10-13 23:18:31 -07:00
Kartik Agaram 5ece295328 4637 - subx: support multiple input files 2018-10-01 12:16:05 -07:00
Kartik Agaram 745c582e28 4636 2018-10-01 11:29:00 -07:00
Kartik Agaram ca00f6b97c 4634 2018-10-01 11:09:07 -07:00
Kartik Agaram 75e30d2faa 4633
Detect overlapping segments when loading SubX source code.

This will start to become more of a risk as we start loading multiple files,
juggling multiple segments, etc.
2018-10-01 10:08:57 -07:00
Kartik Agaram 73aa4d14a6 4631 2018-10-01 08:47:15 -07:00
Kartik Agaram 2540fceca5 4630 2018-10-01 08:34:00 -07:00
Kartik Agaram 83c4fbc91c 4629 2018-10-01 08:27:37 -07:00
Kartik Agaram 2813ce0e72 4628 2018-09-30 23:20:33 -07:00
Kartik Agaram cd8395323b 4627 2018-09-30 23:18:55 -07:00
Kartik Agaram 69b004f59b 4626 2018-09-30 23:14:01 -07:00
Kartik Agaram ed79099bf6 4617 2018-09-29 17:45:00 -07:00
Kartik Agaram 630433cd9c 4614 - redo simulated RAM
Now simulated 'Memory' isn't just a single flat array. Instead it knows
about segments and VMAs.

The code segment will always be first, and the data/heap segment will always
be second. The brk() syscall knows about the data segment.

One nice side-effect is that I no longer need to mess with Memory initialization
regardless of where I place my segments.
2018-09-29 10:20:13 -07:00
Kartik Agaram 2b36eee9b1 4502 - support string literals directly in code
Doesn't de-duplicate in the data segment, though. If you use the literal
"foo" a hundred times in your code segment you're gonna spend a hundred
times the space you need to.

We can now simplify our test harness a bit in the factorial app, but we
still have to put in commandline args to compare with manually. We only
support length-prefixed strings, not null-terminated ones.
2018-09-22 22:17:09 -07:00
Kartik Agaram 8998908e63 4565 2018-09-21 10:06:17 -07:00
Kartik Agaram 1a62e61df4 4538 2018-09-07 22:20:29 -07:00
Kartik Agaram a49bc41365 4531 - automatically compute segment addresses 2018-09-01 20:10:06 -07:00
Kartik Agaram 76aace4625 4505 - start warning on jumps without labels
As we climb the ladder of abstraction we'll gradually pull the ladder up
behind ourselves.
2018-08-11 11:09:22 -07:00
Kartik Agaram ad1068b3b4 4500 2018-08-09 21:56:02 -07:00
Kartik Agaram 87f72beede 4495 - nail down a few more error states
It would be confusing to use negative numbers in raw hex. But we'll rely
on programmer taste there.
2018-08-08 23:13:37 -07:00
Kartik Agaram f8bd7ed527 4494
Hacky test. I'm creating a helper to run tests just for this layer. But
I won't be able to do this when I want to selectively run just
transforms below some level.
2018-08-08 16:55:54 -07:00
Kartik Agaram a2001d15a1 4472 - experiment: help read the long lines 2018-08-04 00:34:38 -07:00
Kartik Agaram 4718a77ce2 4444
More tracing reorg.
2018-07-27 12:35:49 -07:00
Kartik Agaram 069ed1c879 4442
Clean up trace levels everywhere in SubX.
2018-07-27 11:55:47 -07:00
Kartik Agaram 3f4bbe9e5f 4434
Key core data structures by hex bytes in text rather than opcode
numbers. Saves us round trips of having to parse and reparse strings,
and also allows us to more easily ignore unexpected non-hex words in
each transform. We'll use this ability next when we start inserting
labels.
2018-07-27 10:15:03 -07:00
Kartik Agaram 4db6b37034 4425
Better name for a layer.
2018-07-26 15:53:21 -07:00