Commit Graph

131 Commits

Author SHA1 Message Date
Kartik Agaram 431627b242 4886 2018-12-28 21:26:42 -08:00
Kartik Agaram 6a7eaa81ee 4883 - rudimentary memory allocator 2018-12-28 11:14:29 -08:00
Kartik Agaram 5a9795bb66 4881 2018-12-28 08:56:21 -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 f9ec61327a 4862 2018-12-09 23:37:34 -08:00
Kartik Agaram 5262ed0de3 4861 2018-12-09 22:46:39 -08:00
Kartik Agaram 42a933078c 4860 - stage 1 of SubX compiler in SubX is done!
I'm imagining 3 core stages total:
  1. convert text hex bytes -> binary (✓)
  2. pack and reorder operands
  3. compute label addresses

(Not including extras like error-checking.)
2018-12-09 21:18:05 -08:00
Kartik Agaram c91d67a29b 4859 2018-12-09 21:08:06 -08:00
Kartik Agaram 780d868502 4856
Fix CI.
2018-12-06 12:55:22 -08:00
Kartik Agaram 09944ba6a8 4854 2018-12-06 12:52:38 -08:00
Kartik Agaram 24e3796c23 4853 2018-12-06 12:27:06 -08:00
Kartik Agaram 48140fcd3f 4851
Bugfix in scenarios where scan-next-byte needs to abort.

I'm starting to have trouble keeping strings, streams and buffered-files
straight.
2018-12-06 12:07:48 -08:00
Kartik Agaram 272408b06b 4850 2018-12-06 11:11:43 -08:00
Kartik Agaram e9909be374 4849 2018-12-06 11:01:23 -08:00
Kartik Agaram a966881b6e 4848 2018-12-06 10:50:26 -08:00
Kartik Agaram 81605224f0 4847 2018-12-06 09:41:40 -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 33cf1f90be 4845 2018-12-06 00:42:12 -08:00
Kartik Agaram 0becf53645 4844 2018-12-06 00:18:13 -08:00
Kartik Agaram 257ca35ab4 4845
Making progress on hex1 (http://web.archive.org/web/20061108010907/http://www.rano.org/bcompiler.html)
2018-12-06 00:16:01 -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 cf02c20bb0 4832
Let's start adding ':end' labels in all functions, just because it helps
us visualize where function calls end in traces, thanks to the '--map'
commandline argument.
2018-12-04 00:29:06 -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 5082923e81 4826 2018-12-03 16:34: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 0043952064 4819 2018-12-02 16:58:30 -08:00
Kartik Agaram c98d4b1c6a 4818 2018-12-02 14:41:21 -08:00
Kartik Agaram f44c595267 4815 2018-12-02 11:08:30 -08:00
Kartik Agaram 54e5128a14 4813 2018-12-01 12:44:10 -08:00
Kartik Agaram c7d45d918b 4812 2018-11-30 22:57:52 -08:00
Kartik Agaram 87c606ee06 4810 2018-11-30 16:56:35 -08:00
Kartik Agaram 9d27e966b5 4808 - clean up comments in all subx files 2018-11-30 16:45:15 -08:00
Kartik Agaram f52bc40d6f 4803 2018-11-30 11:23:08 -08:00
Kartik Agaram ee9a9237d6 4802
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
2018-11-30 11:13:36 -08:00
Kartik Agaram 6030d7e2e5 4801
Reindent all SubX code to make some room for the new comment style.
2018-11-30 10:54:42 -08:00
Kartik Agaram e9661581f0 4800 2018-11-30 10:37:14 -08:00
Kartik Agaram 2b7ba2a56a 4799 2018-11-30 10:35:03 -08:00
Kartik Agaram a20b51bdb7 4797 2018-11-30 09:45:07 -08:00
Kartik Agaram c56d803cd8 4796 2018-11-30 09:43:49 -08:00
Kartik Agaram 50dcc0c122 4776
Crenshaw compiler now runs natively as well.

It turns out I was misreading the Intel manual, and the jump instructions
that I thought take disp16 operands actually take disp32 operands by default
on both i686 and x86_64 processors. The disp16 versions are some holdover
from the 16-bit days.

This was the first time I've used one of these erstwhile-disp16 instructions,
but I still haven't tested most of them. We'll see if we run into future
issues.
2018-11-25 13:46:53 -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