Commit Graph

63 Commits

Author SHA1 Message Date
Kartik Agaram 2eb174d697 4908
Fix CI.

a) Update canonical binaries.
b) Fix an out-of-bounds access in `clear-stream`. This also required supporting
   a new instruction in `subx run` to load an imm8 into rm8.
2019-01-05 01:07:37 -08:00
Kartik Agaram dd9ba09a7c 4888
We only can't use rm32=5 when mod=0. Totally fine when it's mod=1.
2018-12-29 13:36:06 -08:00
Kartik Agaram 6a7eaa81ee 4883 - rudimentary memory allocator 2018-12-28 11:14:29 -08:00
Kartik Agaram 044b413021 4879 2018-12-28 02:07:11 -08:00
Kartik Agaram 3d4fba4d12 4865
More mnemonic register usage in write-stream.
2018-12-10 09:55:46 -08:00
Kartik Agaram 3a4d870730 4864
Our first buffer overflow!
2018-12-10 00:17:47 -08:00
Kartik Agaram 33e7c3a751 4846
Clean up a few things:

a) Call scan-next-byte in hex.subx with the right number of args. Turns
out tests continue to work fine if they never use the other args.

b) Tear down a test for 'stop' in the right order. Not important since we
have no EBP to restore. But can still be misleading.

c) Have 'check-ints-equal' return nothing. Handy for it to not mess up
EAX. I never use the result anyway, and the name also is imperative suggesting
callers won't expect a return value.
2018-12-06 09:34:55 -08:00
Kartik Agaram 0becf53645 4844 2018-12-06 00:18:13 -08:00
Kartik Agaram 79328f9ad6 4841
New helper: print an error message, then a numeric byte, then abort.
2018-12-04 12:26:27 -08:00
Kartik Agaram a94b60b5cc 4840
New helper: printing a string to a buffered file.
2018-12-04 12:16:17 -08:00
Kartik Agaram af5797eeff 4838
Better to use EDI as a mnemonic for 'destination'.
2018-12-04 10:40:01 -08:00
Kartik Agaram 9e03e2bd37 4837
Let's standardize to use opcode 39 rather than 3b by default.
2018-12-04 10:19:18 -08:00
Kartik Agaram 381d80f8a4 4834
Fix CI since 4827.
2018-12-04 09:56:23 -08:00
Kartik Agaram a9cce7121a 4833 2018-12-04 00:30:00 -08:00
Kartik Agaram 83822d6324 4828 - writing to buffered-file
This is likely a sub-optimal interface, but I'm trying not to agonize.
The whole point of Mu is to permit radical changes at any point in time.
2018-12-03 17:08:53 -08:00
Kartik Agaram 5e27c7f13e 4827
I was 'returning' a phantom value from 'write' when the underlying '_write'
returns nothing.

In general, returning counts of bytes written is not so useful for error
checking when my primitives abstract away from that. We'll come back to
error signalling later.
2018-12-03 16:44:16 -08:00
Kartik Agaram 1eb9cc5679 4822
Fix CI.

It's kind of a hassle (and wasteful) that I need to redefine 'main' in
every single layer.
2018-12-03 11:41:33 -08:00
Kartik Agaram 0eb0f69616 4821 2018-12-02 22:41:28 -08:00
Kartik Agaram 87c606ee06 4810 2018-11-30 16:56:35 -08:00
Kartik Agaram 33fdc60b16 4775
Start with an exactly corresponding version to Crenshaw 2-1: single-digit
numbers. The only change: we assume the number is in hex.

The next version now supports multi-digit hex numbers.
2018-11-24 23:26:14 -08:00
Kartik Agaram 31ff94214b 4774
Simplification.
2018-11-24 23:14:21 -08:00
Kartik Agaram 732cf4e7cc 4773 - done with crenshaw chapter 2-1
In the process I had to fix a couple more bugs in support for disp16 instructions.
2018-11-24 23:06:55 -08:00
Kartik Agaram 5f6edeea51 4768 2018-11-24 15:06:35 -08:00
Kartik Agaram e345224833 4764 2018-11-23 16:19:06 -08:00
Kartik Agaram d373c008b3 4763 - back to the 'trivial' crenshaw2-1 compiler
This time I've ported (and test-driven) 'GetChar' and 'GetNum'. The new
tests bring together our new testable interfaces for read() and exit().
2018-11-23 00:42:30 -08:00
Kartik Agaram fa04aebdc2 4756
Long-standing and long-copied typo has been messing with our exit status
on test failures.
2018-11-19 23:34:20 -08:00
Kartik Agaram bd6f1928d7 4755 - read-byte (sometimes called getchar) 2018-11-19 23:11:00 -08:00
Kartik Agaram b31455f81d 4747 - subx: 'read' primitive 2018-11-18 00:17:29 -08:00
Kartik Agaram 267fd885b2 4745 2018-11-17 20:45:22 -08:00
Kartik Agaram 11a5fffade 4743 2018-11-12 22:00:51 -08:00
Kartik Agaram 8b0e960dbb 4741
Extract a helper that we'll need for 'read'.
2018-10-30 23:10:49 -07:00
Kartik Agaram b3d8c144a4 4740 2018-10-30 22:46:05 -07:00
Kartik Agaram f94442fe2d 4736
We'll use a common stream data structure for input and output streams.

Having separate types makes more sense in a more high-level language, where
we have type checking and where functions for handling the different types
are more concise. But in machine code the sweet spot is more toward fewer
types.
2018-10-29 16:34:47 -07:00
Kartik Agaram bb5cc54f96 4732 2018-10-28 12:45:11 -07:00
Kartik Agaram eb9087635b 4729
Start injecting all dependencies in the Crenshaw compiler app.

In the process I realized the non-fake code path of 'stop' had a bug.
2018-10-28 00:19:46 -07:00
Kartik Agaram 0939de6373 4721 2018-10-24 22:53:45 -07:00
Kartik Agaram f3612481b1 4713
Initial sketch of a dependency-injected wrapper around the exit() syscall.

I don't have the primitives yet, just a sketch of how they should work
-- and a passing test for non-local jumps without support for passing the
exit status to the caller.
2018-10-21 21:17:22 -07:00
Kartik Agaram b847538071 4711
Extract a helper for appending strings to raw buffers.

I'd been resisting this idea, but it actually turns out to be a pretty
clean abstraction in the end.
2018-10-17 22:31:39 -07:00
Kartik Agaram 4cc517e0de 4710
Start using write() instead of _write().. and we promptly find a typo when
dealing with real file descriptors.
2018-10-17 08:19:03 -07:00
Kartik Agaram 3d6450f216 4707 - subx: dependency-injected write() primitive 2018-10-16 23:44:31 -07:00
Kartik Agaram 6528a08992 4699 2018-10-14 22:25:57 -07:00
Kartik Agaram 0e0a90420e 4697 2018-10-14 00:29:48 -07:00
Kartik Agaram a8c6eda1cf 4691
All tests now once again run the same natively and on VM.
2018-10-13 21:01:01 -07:00
Kartik Agaram c25d9aa42a 4684
Turns out the tests for 'trace' have been broken in native mode since the
original commit (4674). Dangers of running my tests on Darwin, where I
can't run them natively.

The test failures didn't get flagged on CI because I'd forgotten to update
the exit code of the factorial app in commit 4664. At least that's fixed
in this commit.
2018-10-11 00:08:50 -07:00
Kartik Agaram 80b6f47e64 4682 - subx: start testing all layers of 'library' 2018-10-10 22:22:48 -07:00
Kartik Agaram 33ad085125 4674
subx: append to trace
2018-10-08 22:50:53 -07:00
Kartik Agaram 03d50cc83c 4667
Standardize on hyphens in all names.
And we'll use colons for namespacing labels in functions.
2018-10-05 19:49:47 -07:00
Kartik Agaram 15ae0717ba 4664 - subx: reflect test failures in exit status 2018-10-05 13:33:14 -07:00
Kartik Agaram bccaa72227 4661
Make segment management a little more consistent between initial segments
and add-on segments (using `mmap`).
2018-10-04 23:23:48 -07:00
Kartik Agaram d11372f6d0 4658 - subx: string_equal 2018-10-02 22:19:35 -07:00