about summary refs log tree commit diff stats
Commit message (Collapse)AuthorAgeFilesLines
* 4612Kartik Agaram2018-09-291-11/+16
|
* 4611Kartik Agaram2018-09-291-3/+4
|
* 4520Kartik Agaram2018-09-2624-572/+580
|
* 4519Kartik Agaram2018-09-261-3/+3
|
* 4518Kartik Agaram2018-09-246-53/+158
|
* 4517Kartik Agaram2018-09-243-17/+17
|
* 4516Kartik K. Agaram2018-09-2412-98/+130
| | | | | | | More calling convention tweaks. Use EBP to get consistently at parameters and locals. Always put the first function argument closest to EBP.
* 4515Kartik K. Agaram2018-09-241-1/+9
| | | | | New '--dump' commandline arg to incrementally print trace lines to stderr as they're emitted.
* 4514Kartik Agaram2018-09-242-3/+11
| | | | Get the calling convention right, per http://www.cs.virginia.edu/~evans/cs216/guides/x86.html
* 4513Kartik Agaram2018-09-242-8/+0
|
* 4512Kartik Agaram2018-09-2324-1748/+2497
|
* 4511Kartik Agaram2018-09-231-0/+0
|
* 4510Kartik Agaram2018-09-232-4/+270
| | | | | Add the test harness to the crenshaw compiler. Though we aren't calling it yet. But that's because we aren't actually doing anything useful yet.
* 4509Kartik Agaram2018-09-231-19/+4
| | | | Back to the Crenshaw compiler. Start by using string literals.
* 4508Kartik Agaram2018-09-232-20/+184
| | | | Upgrade the test harness for the factorial "app" from ex11.
* 4507Kartik Agaram2018-09-232-0/+304
| | | | | | | | New helper: compare a null-terminated string (from argv) with a length-prefixed string (anywhere else). As long as ex11 continues to pass we can copy the function and its tests to other programs.
* 4506Kartik Agaram2018-09-232-0/+13
| | | | | | | | | | | | 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.
* 4505Kartik Agaram2018-09-233-8/+37
| | | | | | | | | | | | 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.
* 4504Kartik Agaram2018-09-237-0/+225
|
* 4503Kartik Agaram2018-09-227-14/+42
| | | | Include LEA (load effective address) in the SubX subset of x86 ISA.
* 4502 - support string literals directly in codeKartik Agaram2018-09-224-45/+243
| | | | | | | | | | 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.
* 4591Kartik Agaram2018-09-225-27/+27
|
* 4590Kartik Agaram2018-09-223-2/+2
|
* 4589Kartik Agaram2018-09-221-12/+12
|
* 4588Kartik Agaram2018-09-2239-2393/+3381
|
* 4587Kartik Agaram2018-09-227-148/+0
|
* 4586 - factorial checks commandline to run testsKartik Agaram2018-09-212-15/+85
| | | | | No automated tests for argv_equal because we need it to run automated tests. But maybe we should have them anyway.
* 4585Kartik Agaram2018-09-212-72/+0
|
* 4584 - discrepancy between SubX and native x86Kartik Agaram2018-09-213-8/+88
| | | | | | | | | | | | | | | | | | | | | | | | | One of the more painful things I had to debug with machine code. Tricks I used can be seen in ex10.subx: - printing argv[1] in various places - printing a single 'X' in various places to count how many times we get to different instructions - exiting with the current value of EAX in various places I repeatedly went down the wrong trail in several ways: - forgetting that the problem lay in native runs, and accidentally switching to subx runs during debugging. - forgetting to pass commandline args, because ex10 doesn't check its argv - writing the wrong comment for an instruction, and then miscalculating the set of registers that need to be saved. - forgetting that syscalls clobber EAX. Debugging native runs is hard, because you have to write non-trivial code to instrument the binary, and instrumentation can itself be buggy. When we finally tracked it down, I recognized the problem immediately. I'd meant to confirm the behavior of opcode 8a against bare metal, and then forgot. In any case, opcode 8a was inconsistent with 88. Sloppy.
* 4583Kartik Agaram2018-09-211-1/+1
|
* 4582Kartik Agaram2018-09-211-0/+0
| | | | subx/examples/ex10 doesn't currently run natively. Grr..
* 4581Kartik Agaram2018-09-2112-33/+33
| | | | | | | | | | | | Even more cuddling. We want to keep lines short where the opcode and operands are self-explanatory. If there are any implicit registers, etc., we'll continue to do the table layout. The first two columns look messy now; let's see how this goes. Maybe I'll give up on the tabular layout altogether, just string args with a single space.
* 4580Kartik Agaram2018-09-211-4/+4
| | | | | Since we're cuddling jump/call args next to the opcode, we can have longer labels without messing up the layout!
* 4579Kartik Agaram2018-09-212-0/+67
| | | | | | | | | | | | New example program: ascii null-terminated string comparison I'd hoped this would be a stepping stone to supporting general ascii comparison, but we're planning to use size-prefixed rather than null-terminated arrays everywhere. The only exception is commandline arguments, which will remain null-terminated to interoperate with Linux. So I'm going to need separate functions for "compare with argv" and for general string comparison.
* 4578 - subx: implement inc/dec operationsKartik Agaram2018-09-214-18/+162
|
* 4577Kartik Agaram2018-09-211-1/+1
|
* 4576Kartik Agaram2018-09-213-11/+11
|
* 4575Kartik Agaram2018-09-212-0/+49
| | | | | | | | New example, just to fix in my head how arguments go on the stack. It's possible I'm still confused about the order callers push args in to the stack. But even if this violates the calling convention, it should still run.
* 4574Kartik Agaram2018-09-211-1/+1
|
* 4573Kartik Agaram2018-09-213-3/+3
|
* 4572Kartik Agaram2018-09-211-1/+3
|
* 4571Kartik Agaram2018-09-211-66/+74
|
* 4570Kartik Agaram2018-09-211-4/+16
|
* 4569Kartik Agaram2018-09-211-2/+2
|
* 4568Kartik Agaram2018-09-212-3/+12
| | | | Get the 'edit' script working again with the 'EE' command in Vim.
* 4567 - support automated tests in SubXKartik Agaram2018-09-213-11/+179
| | | | | | | | | 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.
* 4566Kartik Agaram2018-09-211-2/+2
| | | | | Neither jump nor call instructions support immediates. Drop that. The only form of absolute addressing relies on rm32.
* 4565Kartik Agaram2018-09-213-3/+22
|
* 4564Kartik Agaram2018-09-202-5/+5
|
* 4563Kartik Agaram2018-09-201-0/+15
|