Commit Graph

27 Commits

Author SHA1 Message Date
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
Kartik Agaram d25e51dc0f 4644 2018-10-01 15:53:44 -07:00
Kartik Agaram 1666b12f37 4641 2018-10-01 14:21:27 -07:00
Kartik Agaram 57628c0e44 4638 - extract some common libraries from apps
I'm still trying to figure out what the defaults should be. At the moment
you have to explicitly pass in every file you want loaded into the output
binary. Maybe that control is a good thing. The examples need no libraries
so far.
2018-10-01 12:27:39 -07:00
Kartik Agaram bc3e572acd 4518 2018-09-24 23:49:43 -07:00
Kartik K. Agaram c5d9a32fe6 4516
More calling convention tweaks.

Use EBP to get consistently at parameters and locals.
Always put the first function argument closest to EBP.
2018-09-24 22:55:37 -07:00
Kartik Agaram ffa45b450b 4514
Get the calling convention right, per http://www.cs.virginia.edu/~evans/cs216/guides/x86.html
2018-09-24 17:28:48 -07:00
Kartik Agaram fd0ab85567 4513 2018-09-24 17:22:09 -07:00
Kartik Agaram 76cb753a49 4511 2018-09-23 21:29:48 -07:00
Kartik Agaram 20d9875459 4508
Upgrade the test harness for the factorial "app" from ex11.
2018-09-23 21:01:28 -07:00
Kartik Agaram bf86f7f39d 4506
check_ints_equal now prints a newline after the failure message on failure.

We still don't know how to print a final newline after all the tests have
run, for the common case when all tests pass.

Ideally I could just emit a few instructions to `run_tests`. But I'd also
need to add a variable for the newline to the data segment. Or I need some
literal syntax for newlines in strings. We don't have support for backslash-escapes
yet.
2018-09-23 12:12:02 -07:00
Kartik Agaram d48cfd0f36 4505
Extract a helper from the factorial unit test: check_ints_equal.

Start of a vocabulary for unit tests.

I *could* also start thinking of supporting multi-file programs, but I'm
going to resist the temptation for now. Copy helpers as necessary, and
allow them to mutate and diverge for a while before we pummel them into
a Procrustean "standard library". Extracting a body of shared code immediately
starts to discourage innovation in the shared code.
2018-09-23 11:17:11 -07:00
Kartik Agaram 3f8597bc3d 4586 - factorial checks commandline to run tests
No automated tests for argv_equal because we need it to run automated tests.
But maybe we should have them anyway.
2018-09-21 23:52:48 -07:00
Kartik Agaram caaeccd68e 4567 - support automated tests in SubX
All it takes is to code-generate a simple function called 'run_tests' that
calls all functions starting with 'test_' one by one.

I've temporarily switched the factorial app to run as a test. But that's
temporary, because all the code to print '.' vs 'F' needs to get extracted
out into a helper.
2018-09-21 13:44:16 -07:00
Kartik Agaram a5a9c2afd6 4554 2018-09-20 15:50:05 -07:00
Kartik Agaram e07a3f2886 4537
Streamline the factorial function; we don't need to save a stack variable
into a register before operating on it. All instructions can take a stack
variable directly.

In the process we found two bugs:

a) Opcode f7 was not implemented correctly. It was internally consistent
but I'd never validated it against a natively running program. Turns out
it encodes multiple instructions, not just 'not'.

b) The way we look up imm32 operands was sometimes reading them before
disp8/disp32 operands.
2018-09-07 22:19:13 -07:00
Kartik Agaram 6ff9ce26e8 4530 - create an apps/ directory 2018-09-01 10:54:20 -07:00