about summary refs log tree commit diff stats
path: root/subx/examples
Commit message (Collapse)AuthorAgeFilesLines
* 4847Kartik Agaram2018-12-064-4/+4
|
* 4824Kartik Agaram2018-12-032-9/+9
|
* 4819Kartik Agaram2018-12-021-3/+3
|
* 4818Kartik Agaram2018-12-021-2/+2
|
* 4817Kartik Agaram2018-12-021-1/+1
|
* 4808 - clean up comments in all subx filesKartik Agaram2018-11-3012-80/+83
|
* 4802Kartik Agaram2018-11-3012-118/+118
| | | | | | | | | | | | | | | | 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-3010-460/+460
| | | | Reindent all SubX code to make some room for the new comment style.
* 4792Kartik Agaram2018-11-281-2/+2
| | | | Thanks Pelle Hjek for the feedback: http://arclanguage.org/item?id=20870
* 4780Kartik Agaram2018-11-2610-1/+11
|
* 4757Kartik Agaram2018-11-204-40/+40
| | | | | | Let's start highlighting all global variables in Red. Assembly programming has a tendency to over-use them. They're a necessary evil, but we should minimize the number of functions that access them.
* 4731Kartik Agaram2018-10-281-3/+3
|
* 4698Kartik Agaram2018-10-146-27/+27
|
* 4669Kartik Agaram2018-10-055-50/+40
|
* 4668Kartik Agaram2018-10-0512-76/+76
|
* 4667Kartik Agaram2018-10-056-96/+98
| | | | | Standardize on hyphens in all names. And we'll use colons for namespacing labels in functions.
* 4662Kartik Agaram2018-10-0512-9/+15
|
* 4661Kartik Agaram2018-10-0412-0/+0
| | | | | Make segment management a little more consistent between initial segments and add-on segments (using `mmap`).
* 4655Kartik Agaram2018-10-021-2/+2
|
* 4650Kartik Agaram2018-10-024-21/+21
|
* 4646Kartik Agaram2018-10-011-1/+1
|
* 4644Kartik Agaram2018-10-0115-84/+84
|
* 4643Kartik Agaram2018-10-012-11/+11
|
* 4641Kartik Agaram2018-10-012-52/+53
|
* 4639Kartik Agaram2018-10-0112-36/+36
|
* 4624Kartik Agaram2018-09-3012-12/+12
| | | | | | | | 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.
* 4622Kartik Agaram2018-09-302-20/+0
| | | | | When I started SubX I imagined that being able to write machine code directly was a feature. Now it's just a hole I haven't bothered closing yet.
* 4619 - new syscall: mmap()Kartik Agaram2018-09-292-0/+43
|
* 4618Kartik Agaram2018-09-291-0/+5
|
* 4616 - fix subx/examples/ex7Kartik Agaram2018-09-291-0/+0
| | | | | | | | | It was broken since I added support for global variables, back on Sep 1. One other subtle thing I've improved is the name `looks_like_hex_int`. We can now distinguish in the pack-operands transform between ignoring 'foo' because it doesn't look like a number, and immediately flagging '0xfoo' as an error because it *should* be a number.
* 4615Kartik Agaram2018-09-291-0/+0
|
* 4518Kartik Agaram2018-09-242-9/+41
|
* 4517Kartik Agaram2018-09-241-4/+4
|
* 4516Kartik K. Agaram2018-09-248-56/+66
| | | | | | | More calling convention tweaks. Use EBP to get consistently at parameters and locals. Always put the first function argument closest to EBP.
* 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.
* 4503Kartik Agaram2018-09-224-11/+2
| | | | Include LEA (load effective address) in the SubX subset of x86 ISA.
* 4591Kartik Agaram2018-09-224-8/+8
|
* 4590Kartik Agaram2018-09-223-2/+2
|
* 4589Kartik Agaram2018-09-221-12/+12
|
* 4587Kartik Agaram2018-09-226-127/+0
|
* 4585Kartik Agaram2018-09-212-72/+0
|
* 4584 - discrepancy between SubX and native x86Kartik Agaram2018-09-212-1/+76
| | | | | | | | | | | | | | | | | | | | | | | | | 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-2110-23/+23
| | | | | | | | | | | | 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.
* 4577Kartik Agaram2018-09-211-1/+1
|
* 4576Kartik Agaram2018-09-212-5/+5
|
* 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.