about summary refs log tree commit diff stats
path: root/subx/apps/factorial.subx
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'master' into surveyKartik Agaram2019-07-031-1/+1
|\ | | | | | | | | | | High time we pulled in the final changes to dquotes. In the process we fix one recently introduced duplicate symbol.
| * 5213Kartik Agaram2019-05-201-1/+1
| |
* | .Kartik Agaram2019-06-121-4/+0
| | | | | | | | | | Now that we don't have to edit code to run a single test, delete that commented out fragment everywhere.
* | new primitive: parse-array-of-intsKartik Agaram2019-05-251-0/+9
|/ | | | | | | | | | Mostly for tests. For every new type we want to compare in a test, we're now going to start using some primitive that can parse its value from string. In this manner we can get syntax for literals in machine code. Open question: parsing aggregates of aggregates. Like an array of structs. This is the first time we allocate from the heap in standard library tests. So we now need to start initializing the heap in all our apps.
* 5037Kartik Agaram2019-03-291-1/+1
|
* 4981 - no, go back to 3 phasesKartik Agaram2019-02-181-1/+6
| | | | | | | | | | | | | 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.
* 4961Kartik Agaram2019-02-141-1/+1
|
* 4933Kartik Agaram2019-01-161-1/+1
|
* 4931Kartik Agaram2019-01-161-1/+0
|
* 4893Kartik Agaram2018-12-301-1/+1
|
* 4888Kartik Agaram2018-12-291-5/+5
| | | | We only can't use rm32=5 when mod=0. Totally fine when it's mod=1.
* 4881Kartik Agaram2018-12-281-1/+1
|
* 4847Kartik Agaram2018-12-061-1/+1
|
* 4819Kartik Agaram2018-12-021-1/+1
|
* 4812Kartik Agaram2018-11-301-2/+2
|
* 4808 - clean up comments in all subx filesKartik Agaram2018-11-301-10/+10
|
* 4802Kartik Agaram2018-11-301-22/+22
| | | | | | | | | | | | | | | | Some automated commenting cleanup. Still needs more careful manual scanning. sed -i 's/^# 1-3/# . 1-3/' *.subx */*.subx sed -i 's/^# op/# . op/' *.subx */*.subx sed -i 's/# vim/# . . vim/' *.subx */*.subx sed -i 's/^ # push args/ # . . push args/' *.subx */*.subx sed -i 's/^ # discard args/ # . . discard args/' *.subx */*.subx sed -i 's/^ # call/ # . . call/' *.subx */*.subx sed -i 's/^ # prolog/ # . prolog/' *.subx */*.subx sed -i 's/^ # epilog/ # . epilog/' *.subx */*.subx sed -i 's/^ # save registers/ # . save registers/' *.subx */*.subx sed -i 's/^ # restore registers/ # . restore registers/' *.subx */*.subx sed -i 's/ operand / register /' *.subx */*.subx
* 4801Kartik Agaram2018-11-301-63/+63
| | | | Reindent all SubX code to make some room for the new comment style.
* 4731Kartik Agaram2018-10-281-5/+5
|
* 4703Kartik Agaram2018-10-161-4/+4
|
* 4700Kartik Agaram2018-10-161-2/+2
|
* 4684Kartik Agaram2018-10-111-2/+3
| | | | | | | | | | 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.
* 4670Kartik Agaram2018-10-051-1/+1
|
* 4668Kartik Agaram2018-10-051-2/+2
|
* 4667Kartik Agaram2018-10-051-11/+11
| | | | | Standardize on hyphens in all names. And we'll use colons for namespacing labels in functions.
* 4663Kartik Agaram2018-10-051-1/+1
|
* 4662Kartik Agaram2018-10-051-1/+1
|
* 4655Kartik Agaram2018-10-021-1/+1
|
* 4653Kartik Agaram2018-10-021-3/+3
|
* 4651Kartik Agaram2018-10-021-1/+3
|
* 4644Kartik Agaram2018-10-011-11/+11
|
* 4641Kartik Agaram2018-10-011-1/+1
|
* 4638 - extract some common libraries from appsKartik Agaram2018-10-011-321/+1
| | | | | | | 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.
* 4624Kartik Agaram2018-09-301-1/+1
| | | | | | | | Start requiring a '-o' flag to designate the output binary when translating. Things currently get funky if you pass in multiple inputs, but that's ok. This is the first step to supporting multiple input files for a single output binary.
* 4518Kartik Agaram2018-09-241-8/+41
|
* 4517Kartik Agaram2018-09-241-5/+5
|
* 4516Kartik K. Agaram2018-09-241-38/+50
| | | | | | | More calling convention tweaks. Use EBP to get consistently at parameters and locals. Always put the first function argument closest to EBP.
* 4514Kartik Agaram2018-09-241-3/+11
| | | | Get the calling convention right, per http://www.cs.virginia.edu/~evans/cs216/guides/x86.html
* 4513Kartik Agaram2018-09-241-8/+0
|
* 4508Kartik Agaram2018-09-231-20/+184
| | | | Upgrade the test harness for the factorial "app" from ex11.
* 4506Kartik Agaram2018-09-231-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-231-8/+27
| | | | | | | | | | | | 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.
* 4502 - support string literals directly in codeKartik Agaram2018-09-221-14/+2
| | | | | | | | | | 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-221-19/+19
|
* 4586 - factorial checks commandline to run testsKartik Agaram2018-09-211-15/+85
| | | | | No automated tests for argv_equal because we need it to run automated tests. But maybe we should have them anyway.
* 4581Kartik Agaram2018-09-211-2/+2
| | | | | | | | | | | | 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.
* 4567 - support automated tests in SubXKartik Agaram2018-09-211-11/+75
| | | | | | | | | 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.
* 4554Kartik Agaram2018-09-201-2/+2
|
* 4537Kartik Agaram2018-09-071-5/+3
| | | | | | | | | | | | | | | 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.
* 4531 - automatically compute segment addressesKartik Agaram2018-09-011-1/+1
|