Commit Graph

412 Commits

Author SHA1 Message Date
Kartik Agaram
88d690ccad 6862
Fix CI.
2020-09-26 20:00:54 -07:00
Kartik Agaram
1fc5ce90ca 6846 2020-09-23 22:45:04 -07:00
Kartik Agaram
e655f673b5 6829 - tile: colorize values on the stack 2020-09-21 21:27:44 -07:00
Kartik Agaram
a085820e21 6809 2020-09-19 22:11:11 -07:00
Kartik Agaram
a83cde9663 6802 - plug a gaping hole in the Mu translator
This issue hasn't been noticed until now because I haven't been using variables
on the stack much.
2020-09-19 16:24:28 -07:00
Kartik Agaram
deda3f49cf 6795
Fix CI since commit 6787.
2020-09-16 19:29:07 -07:00
Kartik Agaram
37fd51f754 6783
An extra test that should have been in commit 6781.
2020-09-16 08:31:10 -07:00
Kartik Agaram
ccbda3fffd 6782
Regression: segfault on `fn foo` without a block

I really need to turn the list of scenarios considered before populate-mu-function-header
into tests.
2020-09-15 22:56:15 -07:00
Kartik Agaram
ae470b42f1 6781 - new app: RPN (postfix) calculator
This was surprisingly hard; bugs discovered all over the place.
2020-09-15 22:52:41 -07:00
Kartik Agaram
abfdaf58bb 6779
Looks like Linux turns reads from stdout/stderr into stdin!
2020-09-14 21:56:10 -07:00
Kartik Agaram
6b41ca6d95 6777
Print answers in decimal in apps/arith.mu
2020-09-14 21:14:04 -07:00
Kartik Agaram
492fb2783f 6769 - support for creating fake files in Mu tests 2020-09-10 23:00:19 -07:00
Kartik Agaram
6b36e4dbc7 6760
Fix a couple of subtle bugs.

- the VM was conditionally reading from the instruction stream, so that
  other bugs got masked by decoding errors.
- push-n-bytes was clobbering eax.
2020-09-08 22:48:47 -07:00
Kartik Agaram
5462619d96 6742 - support for formatting in fake screens
We still need a few primitives, but we can implement these as needed. I'm
ready to call the fake screen done.
2020-09-07 14:18:48 -07:00
Kartik Agaram
cd94852dbc 6733 - read utf-8 'grapheme' from byte stream
No support for combining characters. Graphemes are currently just utf-8
encodings of a single Unicode code-point. No support for code-points that
require more than 32 bits in utf-8.
2020-08-28 23:24:04 -07:00
Kartik Agaram
15b9880136 6727 - bugfix in a multiply instruction
Also more error-detection for this case all across the toolchain.
2020-08-22 14:35:44 -07:00
Kartik Agaram
db894e7968 6726 2020-08-22 14:25:29 -07:00
Kartik Agaram
ef8e98dd06 6725 - support negative literals 2020-08-22 13:59:57 -07:00
Kartik Agaram
38128ae167 6722 2020-08-22 12:35:39 -07:00
Kartik Agaram
e8ffaf29ce 6719 - error-checking for 'index' instructions
1000+ LoC spent; just 300+ excluding tests.

Still one known gap; we don't check the entirety of an array's element
type if it's a compound. So far we just check if say both sides start with
'addr'. Obviously that's not good enough.
2020-08-21 21:32:48 -07:00
Kartik Agaram
be2a94d9b8 6718 2020-08-16 22:43:03 -07:00
Kartik Agaram
208b28303c 6715
There's a question of how we should match array types with a capacity on
ones without. For now we're going to do the simplest possible thing and
just make type-match? more robust. It'll always return false if the types
don't match exactly. For ignoring capacity we'll rely on the checks of
the `address` operation (which don't exist yet). This means we should do
this to pass an address to an array to a function f with signature `f (addr
array int)`:

  var a: (array int 3)
  var b/eax: (addr array int) <- address a
  f b

rather than this:

  var a: (array int 3)
  var b/eax: (addr array int 3) <- address a
  f b

Similar reasoning applies to stream types. Arrays and streams are currently
the only types that can have an optional capacity.
2020-08-03 21:45:41 -07:00
Kartik Agaram
89c9ed80f9 6706 - support utf-8
For example:

  fn main -> r/ebx: int {
    var x/eax: grapheme <- copy 0x9286e2  # code point 0x2192 in utf-8
    print-grapheme-to-real-screen x
    print-string-to-real-screen "\n"
  }

Graphemes must fit in 4 bytes (21 bits for code points). Unclear what we
should do for longer clusters since graphemes are a fixed-size type at
the moment.
2020-08-02 15:50:19 -07:00
Kartik Agaram
0a8e8f4e2f 6704
This is stupid; all this while I've been writing escape sequences to the
screen they've been going out on stderr.
2020-08-02 15:19:27 -07:00
Kartik Agaram
0452b05f5a 6703 - new types: code-point and grapheme
Both have the same size: 4 bytes.

So far I've just renamed print-byte to print-grapheme, but it still behaves
the same.

I'm going to support printing code-points next, but grapheme 'clusters'
spanning multiple code-points won't be supported for some time.
2020-08-02 15:11:52 -07:00
Kartik Agaram
1b79f705b9 6702 2020-08-02 11:51:29 -07:00
Kartik Agaram
7d33cce069 6701 2020-08-02 11:42:59 -07:00
Kartik Agaram
a0da3604a2 6691 - start building a fake screen
There was a bug in defining types containing other user-defined types.
2020-07-31 08:40:56 -07:00
Kartik Agaram
3001235028 6687 - stream-empty? and stream-full? 2020-07-30 19:34:29 -07:00
Kartik Agaram
bae22d720f 6684 - experimental primitives for streams
This is a hacky special case. The alternative would be more general support
for generics.

One observation: we might be able to type-check some primitives using `sig`s.
Only if they don't return anything, since primitives usually need to support
arbitrary registers. I'm not doing that yet, though. It eliminates the
possibility of writing tests for them in mu.subx, which can't see 400.mu.
But it's an alternative:

  sig allocate out: (addr handle _)
  sig populate out: (addr handle array _), n: int
  sig populate-stream out: (addr handle stream _), n: int
  sig read-from-stream s: (addr stream _T), out: (addr _T)
  sig write-to-stream s: (addr stream _T), in: (addr _T)

We could write the tests in Mu. But then we're testing behavior rather
than the code generated. There are trade-offs. By performing type-checking
in mu.subx I retain the option to write both kinds of tests.
2020-07-29 21:41:29 -07:00
Kartik Agaram
129bb8117b 6683 2020-07-28 21:41:00 -07:00
Kartik Agaram
b8df5340fa 6682 - experimental support for streams and slices
Slices contain `addr`s so the same rules apply to them. They can't be stored
in structs and so on. But they may be an efficient temporary while parsing.

Streams are currently a second generic type after arrays, and gradually
strengthening the case to just bite the bullet and support first-class
generics in Mu.
2020-07-28 21:37:32 -07:00
Kartik Agaram
e2c22ad4d9 6681 2020-07-26 22:51:21 -07:00
Kartik Agaram
2b1737363f 6676 - type checks for 'lookup' 2020-07-25 19:11:51 -07:00
Kartik Agaram
4dc20af1bf 6672 - error on addr or array inside type 2020-07-25 15:08:52 -07:00
Kartik Agaram
bf0a6b69dc 6671 - bugfix in generic functions
We need to remember to clear local variables. And there's a good question
here of how Mu supports variables of type stream or table. Or other user-defined
types that inline arrays.
2020-07-25 11:04:34 -07:00
Kartik Agaram
32055c369b 6670 - generic functions
Function signatures can now take type parameters starting with '_'.

Type parameters in a signature match any concrete type in the call. But
they have to be consistent within a single call.

Things I considered but punted on for now:
- having '_' match anything without needing to be consistent. Wildcards
  actually seem harder to understand.
- disallowing top-level '_' types. I'll wait until a concrete use case
  for disallowing.

We still don't support *defining* types with type parameters, so for now
this is only useful for calling functions on arrays or streams or handles.
2020-07-25 10:21:22 -07:00
Kartik Agaram
ba4e33f711 tmp - snapshot of type-parameter support
I think I've got all the stack management down. Time now for the business
logic. There's one failing test.
2020-07-25 09:36:43 -07:00
Kartik Agaram
2a1b9d32d7 6668
type-match? is no longer symmetric; we have to be careful about arg ordering.
2020-07-24 22:10:09 -07:00
Kartik Agaram
750f490b4d 6667 2020-07-24 21:40:18 -07:00
Kartik Agaram
39a4cbdf61 6666 - types starting with '_' now match anything
We still need to perform pattern matching.
2020-07-24 21:34:36 -07:00
Kartik Agaram
c9ea1bd55a 6663 2020-07-24 21:25:46 -07:00
Kartik Agaram
ac6af96c5a 6662 - start support for generics
Mu will be a language with generics -- but no static dispatch.
2020-07-20 22:30:02 -07:00
Kartik Agaram
97dbe33fd4 6660 2020-07-20 21:03:55 -07:00
Kartik Agaram
8cc1ed72c3 6650 - bit-shift operations really working
test input:

  fn foo {
    var y/edx: int <- copy 0
    y <- shift-left 2
    y <- shift-right 2
    y <- shift-right-signed 2
    var x: int
    shift-left x, 2
    shift-right x, 2
    shift-right-signed x, 2
  }

output:

  foo:
    # . prologue
    55/push-ebp
    89/<- %ebp 4/r32/esp
    {
  $foo:0x00000001:loop:
      ff 6/subop/push %edx
      ba/copy-to-edx 0/imm32
      c1/shift 4/subop/left %edx 2/imm8
      c1/shift 5/subop/right-padding-zeroes %edx 2/imm8
      c1/shift 7/subop/right-preserving-sign %edx 2/imm8
      68/push 0/imm32
      c1/shift 4/subop/left *(ebp+0xfffffff8) 2/imm8
      c1/shift 5/subop/right-padding-zeroes *(ebp+0xfffffff8) 2/imm8
      c1/shift 7/subop/right-preserving-sign *(ebp+0xfffffff8) 2/imm8
      81 0/subop/add %esp 0x00000004/imm32
      8f 0/subop/pop %edx
    }
  $foo:0x00000001:break:
    # . epilogue
    89/<- %esp 5/r32/ebp
    5d/pop-to-ebp
    c3/return

test input 2:

  $ cat x.mu
  fn main -> o/ebx: int {
    o <- copy 3
    o <- shift-left 2
  }

output 2:

  $ ./translate_mu x.mu
  $ ./a.elf
  $ echo $?
  12
2020-07-14 22:53:56 -07:00
Kartik Agaram
fd100782cb 6649
Bit-shifts aren't quite right yet. We need to emit /imm8 rather than /imm32.

This commit introduces the field, though we don't use it yet.
2020-07-14 22:33:00 -07:00
Kartik Agaram
ab26c894c8 6648 - bit-shift instructions in Mu
I'm not happy with the names.
2020-07-14 21:42:20 -07:00
Kartik Agaram
5e0ae917d0 6645 - heap allocations in Mu
- allocate var
- populate var, n

Both rely on the type of `var` to compute the size of the allocation. No
need to repeat the name of the type like in C, C++ or Java.
2020-07-13 22:21:26 -07:00
Kartik Agaram
4cb4d4d2d8 6644 2020-07-13 22:08:55 -07:00
Kartik Agaram
725a9579e9 6638 - require '0x' prefix on multi-digit literals
Mu exclusively uses hex everywhere for a consistent programming experience
from machine code up. But we all still tend to say '10' when we mean 'ten'.
Catch that early.
2020-07-11 22:07:48 -07:00
Kartik Agaram
8bf95d294a 6637
Be more consistent about what we interpret as integer literals.
2020-07-11 22:02:31 -07:00
Kartik Agaram
5c86f9be66 6636 2020-07-11 21:33:51 -07:00
Kartik Agaram
355073129b 6635 - bugfix 2020-07-11 21:30:45 -07:00
Kartik Agaram
c5a3f65502 6630 - define type signatures for SubX functions
This was easier than I'd feared.
2020-07-10 23:41:34 -07:00
Kartik Agaram
c1b6ecc874 6628 2020-07-10 21:23:32 -07:00
Kartik Agaram
c532373e29 6626 2020-07-09 12:32:07 -07:00
Kartik Agaram
f16f569060 6622 - new syscalls: time and ntime
As a side-effect I find that my Linode can print ~100k chars/s. At 50 rows
and 200 columns per screen, it's 10 frames/s.
2020-07-08 22:14:42 -07:00
Kartik Agaram
996402e8fd 6604 - new app
https://archive.org/details/akkartik-2min-2020-07-01

In the process I found a bug, added a new syscall, and 'emulated' it.
2020-07-01 16:47:20 -07:00
Kartik Agaram
59cf3ae983 6597 2020-06-29 18:33:52 -07:00
Kartik Agaram
1afc882890 6596 2020-06-29 18:31:17 -07:00
Kartik Agaram
690fa191f1 6595 2020-06-29 18:01:44 -07:00
Kartik Agaram
05dabd816a 6594 - start standardizing the meaning of 'print' 2020-06-29 17:58:01 -07:00
Kartik Agaram
8ce50909c4 6592 - error-checking for integer stmts feels done 2020-06-28 23:25:18 -07:00
Kartik Agaram
9483fdc1fb 6591 2020-06-28 23:17:34 -07:00
Kartik Agaram
4ddc2620f7 6590 2020-06-28 23:10:45 -07:00
Kartik Agaram
896e3bcfb2 6589 2020-06-28 23:09:10 -07:00
Kartik Agaram
d31bd529f7 6588 2020-06-28 18:49:50 -07:00
Kartik Agaram
52d3ee0326 6587 2020-06-28 14:35:45 -07:00
Kartik Agaram
f7a174c2a1 6586 - error-checking for 'get' stmts feels done 2020-06-28 14:23:31 -07:00
Kartik Agaram
1a89b13b9c 6585 2020-06-28 11:50:50 -07:00
Kartik Agaram
bf4fbab76d 6584 2020-06-28 10:19:02 -07:00
Kartik Agaram
60bffdaa49 6583 2020-06-28 09:53:32 -07:00
Kartik Agaram
76a669f689 6582 2020-06-28 09:10:16 -07:00
Kartik Agaram
fbc4544ff8 6581 2020-06-28 08:49:08 -07:00
Kartik Agaram
f58a6acc3f 6579 2020-06-28 00:55:31 -07:00
Kartik Agaram
1da16dd6cb 6578 - redo error if 'get' on unknown field
This commit reimplements commit 6515 to happen during type-checking rather
than as early as possible. That way we naturally get a more informative
error message.
2020-06-27 21:03:43 -07:00
Kartik Agaram
ab42709e14 6577 2020-06-27 14:30:07 -07:00
Kartik Agaram
14d9b56668 6576 2020-06-27 14:23:50 -07:00
Kartik Agaram
ca9dec80b6 6575 2020-06-27 12:13:43 -07:00
Kartik Agaram
3b02c3dfa2 6572
Small change to mu.subx to keep the treeshaker working with it. That's
currently the only place where we prevent jumps across 'functions'.
2020-06-21 17:31:38 -07:00
Kartik Agaram
6bfb565819 6570 - error on use of a clobbered var
All tests now passing, and factorial.mu and all other apps now working.
The new checks caught one problem in a few prototypes.
2020-06-21 17:08:03 -07:00
Kartik Agaram
c70beadc7a 6562
The new failing test is now passing, and so is this manual test that had
been throwing a spurious error:
  fn foo {
    var a/eax: int <- copy 0
    var b/ebx: int <- copy 0
    {
      var a1/eax: int <- copy 0
      var b1/ebx: int <- copy a1
    }
    b <- copy a
  }

However, factorial.mu is still throwing a spurious error.

Some history on this commit's fix: When I moved stack-location tracking
out of the parsing phase (commit 6116, Mar 10) I thoughtlessly moved block-depth
tracking as well. And the reason that happened: I'd somehow gotten by without
ever cleaning up vars from a block during parsing. For all my tests, this
is a troubling sign that I'm not testing enough.

The good news: clean-up-blocks works perfectly during parsing.
2020-06-21 11:06:25 -07:00
Kartik Agaram
d1ad96e038 6556 - check for uses of clobbered vars
Now all tests passing again. In the process I found a bug where one of
my tests actually generated incorrect code.
2020-06-19 23:25:43 -07:00
Kartik Agaram
4d2f171ce1 6553 - Mu: disallow registers esp and ebp 2020-06-19 20:52:37 -07:00
Kartik Agaram
88908608b0 6550 - type-checking for function calls
There were a couple of benign type errors in arith.mu but nowhere else.
2020-06-18 08:57:48 -07:00
Kartik Agaram
9ab613b233 6549 - starting on type checking 2020-06-17 13:59:22 -07:00
Kartik Agaram
5a6d2d0db7 6528 2020-06-15 16:57:39 -07:00
Kartik Agaram
43957d3ce5 6525 2020-06-15 14:16:38 -07:00
Kartik Agaram
39bcd3a8bc 6524 2020-06-15 14:11:11 -07:00
Kartik Agaram
532068bfc6 6523
Still some issues; add some tests. I have more that were passing a couple
of days ago but aren't currently.
2020-06-15 14:06:30 -07:00
Kartik Agaram
89c2b59a5f 6522 - redo support for 'byte'
Before: bytes can't live on the stack, so size(byte) == 1 just for array
elements.

After: bytes mostly can't live on the stack except for function args (which
seem too useful to disallow), so size(byte) == 4 except there's now a new
primitive called element-size for array elements where size(byte) == 1.

Now apps/browse.subx starts working again.
2020-06-15 14:02:41 -07:00
Kartik Agaram
5945986cc5 6521 - new primitive: array size in bytes 2020-06-14 00:40:16 -07:00
Kartik Agaram
ad61776f49 6520 - new app: parse-int
Several bugs fixed in the process, and expectation of further bugs is growing.
I'd somehow started assuming I don't need to have separate cases for rm32
as a register vs mem. That's not right. We might need more reg-reg Primitives.
2020-06-14 00:28:23 -07:00
Kartik Agaram
57f92a9334 6518 - extra args through a whole swathe of places
Most unbelievably, I'd forgotten to pass the output 'out' arg to 'lookup-var'
long before the recent additions of 'err' and 'ed' args. But things continued
to work because an earlier call just happened to leave the arg at just
the right place on the stack. So we only caught all these places when we
had to provide error messages.
2020-06-13 23:05:51 -07:00
Kartik Agaram
ef845524e9 6516 - operations on bytes
Byte-oriented addressing is only supported in a couple of instructions
in SubX. As a result, variables of type 'byte' can't live on the stack,
or in registers 'esi' and 'edi'.
2020-06-13 20:23:51 -07:00
Kartik Agaram
7e55a20ff4 6515 - error if 'get' on unknown field
We can't yet say in the error message precisely where the 'get' occurs.
2020-06-12 23:04:22 -07:00
Kartik Agaram
0e20925078 6511 - start of error-checking
We now raise an error if a variable is declared on the stack with an initializer.
And there are unit tests for this functionality.
2020-06-12 00:43:50 -07:00
Kartik Agaram
73cec3939f 6509 - mu.subx: exit-descriptors everywhere 2020-06-11 08:01:37 -07:00
Kartik Agaram
80f53f4a18 6508 - support null exit-descriptor 2020-06-10 23:34:42 -07:00
Kartik Agaram
7dac9ade15 6507 - use syscall names everywhere 2020-06-10 23:09:30 -07:00
Kartik Agaram
8a065c536e 6479
Fix a stray copy-paste when deciding whether to emit spills for registers
(commit 6464).
2020-06-05 22:06:13 -07:00
Kartik Agaram
8122f5d391 6477
I had a little "optimization" to avoid creating nested blocks if "they weren't
needed". Except, of course, they were. Lose the optimization. Sometimes
we create multiple jumps when a single one would suffice. Ignore that for
now.
2020-06-05 21:54:33 -07:00
Kartik Agaram
cde591e03e 6466 2020-06-04 21:25:38 -07:00
Kartik Agaram
20411cc442 6464 - support temporaries in fn output registers
The rule: emit spills for a register unless the output is written somewhere
in the current block after the current instruction. Including in nested
blocks.

Let's see if this is right.
2020-06-04 20:28:27 -07:00
Kartik Agaram
04b3afd67e 6463 - clean up some duplication
Rather than have two ways to decide whether to emit push/pop instructions,
just record for each var on the 'vars' stack whether we emitted a push
for it, and reuse the decision to emit a pop.
2020-06-03 23:40:52 -07:00
Kartik Agaram
da1a29f121 6462
Stack bug.
2020-06-03 23:09:00 -07:00
Kartik Agaram
91c80ca32c 6461 2020-06-03 22:36:35 -07:00
Kartik Agaram
5aed53d809 6460 2020-06-03 22:32:24 -07:00
Kartik Agaram
69a29fc62c 6459 2020-06-03 00:27:01 -07:00
Kartik Agaram
e38a95ecd9 6458 2020-06-03 00:20:05 -07:00
Kartik Agaram
242a50f229 6441
Just always flush Stdout when printing numbers.
2020-05-29 16:44:40 -07:00
Kartik Agaram
eb40c70e26 6440
Minor reordering; the hacky flush-stdout is now only needed if we ever
call print-int32-to-screen.
2020-05-29 16:41:51 -07:00
Kartik Agaram
967d11f102 6424 2020-05-28 22:48:40 -07:00
Kartik Agaram
b22fa8afd8 6423 - done with sample app 'print-file'
Observations:
  - the orchestration from 'in' to 'addr-in' to '_in-addr' to 'in-addr'
    is quite painful. Once to turn a handle into its address, once to turn
    a handle into the address of its payload, and a third time to switch
    a variable out of the overloaded 'eax' variable to make room for read-byte-buffered.
  - I'm starting to use SubX as an escape hatch for features missing in Mu:
    - access to syscalls (which pass args in registers)
    - access to global variables
2020-05-28 22:41:26 -07:00
Kartik Agaram
583a966d3e 6422 - size-of for handles 2020-05-28 22:31:52 -07:00
Kartik Agaram
3962ac5959 6419 - new primitive for opening files 2020-05-28 21:33:04 -07:00
Kartik Agaram
dd6e4bc789 6415 2020-05-27 23:48:27 -07:00
Kartik Agaram
d3bca9dbfe 6413
Fix CI.
2020-05-27 01:53:16 -07:00
Kartik Agaram
9511ff5cd7 6409 - primitives for text-mode UIs 2020-05-27 00:09:22 -07:00
Kartik Agaram
3b5b19df66 6406 - primitive 'copy-handle' 2020-05-25 19:26:18 -07:00
Kartik Agaram
d1179723a9 6394 - a catastrophic bug
How did new-literal ever work?! Somehow we had eax silently being clobbered
without affecting behavior over like 5 apps. Unsafe languages suck.

Anyways, factorial.mu is now part of CI.
2020-05-24 20:54:12 -07:00
Kartik Agaram
4d14c3fefd 6393 - start running .mu apps in CI 2020-05-24 20:36:31 -07:00
Kartik Agaram
27b1e19ebe 6392 - 'length' instruction done in all complexity 2020-05-24 19:46:47 -07:00
Kartik Agaram
1eecd0934f 6391 2020-05-24 16:42:26 -07:00
Kartik Agaram
156763463d 6390 - return length in elements 2020-05-24 14:48:41 -07:00
Kartik Agaram
4335309233 6388 - fix regression #1 2020-05-24 00:51:52 -07:00
Kartik Agaram
e992b940e4 6387 2020-05-23 13:01:39 -07:00
Kartik Agaram
5bc9a5b72e update binaries
CI should start passing again now.
2020-05-22 16:59:53 -07:00
Kartik Agaram
1f38b75e31 6219 2020-05-18 00:43:34 -07:00
Kartik Agaram
6a1cc7d65a 6216 2020-05-05 14:55:52 -07:00
Kartik Agaram
84a0297229 6208 2020-04-22 16:34:08 -07:00
Kartik Agaram
d6f9813650 6205
Rip out scaffolding for function overloading.
2020-04-15 16:25:04 -07:00
Kartik Agaram
d70fca1c3f 6204 2020-04-15 16:09:04 -07:00
Kartik Agaram
0671315c1a 6203 2020-04-12 02:33:01 -07:00
Kartik Agaram
677f98c6f2 6184
Why the heck are we bumping this pointer? Seems like a bug.
2020-04-05 00:05:36 -07:00
Kartik Agaram
bfcc0f858a 6182 - start of support for safe handles
So far it's unclear how to do this in a series of small commits. Still
nibbling around the edges. In this commit we standardize some terminology:

The length of an array or stream is denominated in the high-level elements.
The _size_ is denominated in bytes.

The thing we encode into the type is always the size, not the length.

There's still an open question of what to do about the Mu `length` operator.
I'd like to modify it to provide the length. Currently it provides the
size. If I can't fix that I'll rename it.
2020-04-03 12:35:53 -07:00
Kartik Agaram
f730f2f2c7 6181 2020-04-03 01:05:01 -07:00
Kartik Agaram
df609237c1 6158 - standardize opcode names
At the lowest level, SubX without syntax sugar uses names without prepositions.
For example, 01 and 03 are both called 'add', irrespective of source and
destination operand. Horizontal space is at a premium, and we rely on the
comments at the end of each line to fully describe what is happening.

Above that, however, we standardize on a slightly different naming convention
across:
  a) SubX with syntax sugar,
  b) Mu, and
  c) the SubX code that the Mu compiler emits.

Conventions, in brief:
  - by default, the source is on the left and destination on the right.
    e.g. add %eax, 1/r32/ecx ("add eax to ecx")
  - prepositions reverse the direction.
    e.g. add-to %eax, 1/r32/ecx ("add ecx to eax")
         subtract-from %eax, 1/r32/ecx ("subtract ecx from eax")
  - by default, comparisons are left to right while 'compare<-' reverses.

Before, I was sometimes swapping args to make the operation more obvious,
but that would complicate the code-generation of the Mu compiler, and it's
nice to be able to read the output of the compiler just like hand-written
code.

One place where SubX differs from Mu: copy opcodes are called '<-' and
'->'. Hopefully that fits with the spirit of Mu rather than the letter
of the 'copy' and 'copy-to' instructions.
2020-03-21 16:51:52 -07:00
Kartik Agaram
c6886c1c97 6157 2020-03-21 15:07:59 -07:00
Kartik Agaram
c48ce3c8bf 6153 - switch 'main' to use Mu strings
At the SubX level we have to put up with null-terminated kernel strings
for commandline args. But so far we haven't done much with them. Rather
than try to support them we'll just convert them transparently to standard
length-prefixed strings.

In the process I realized that it's not quite right to treat the combination
of argc and argv as an array of kernel strings. Argc counts the number
of elements, whereas the length of an array is usually denominated in bytes.
2020-03-15 21:03:12 -07:00
Kartik Agaram
f559236bdf 6152 - fix regression in factorial.mu
I had to amend commit 6148 three times yesterday as I kept finding bugs
by inspection. And yet I stubbornly thought I didn't need a test.
2020-03-15 16:44:55 -07:00
Kartik Agaram
abb66df2c7 6150 - call-by-reference is working 2020-03-14 16:04:57 -07:00
Kartik Agaram
afa4d6bb4c 6149 - pass multi-word objects to functions
This is quite inefficient; don't use it for very large objects.
2020-03-14 15:46:38 -07:00
Kartik Agaram
9655878e1b 6148 2020-03-14 15:31:35 -07:00
Kartik Agaram
999292dfdd 6147 2020-03-14 15:15:46 -07:00
Kartik Agaram
114641e2c8 6145 - 'address' operator
This could be a can of worms, but I think I have a set of checks that will
keep use of addresses type-safe.
2020-03-14 14:46:45 -07:00
Kartik Agaram
ff0f216b41 6133 2020-03-12 00:45:17 -07:00
Kartik Agaram
b50c0e3279 6132 2020-03-12 00:36:36 -07:00
Kartik Agaram
92ca78429c 6131 - operating on arrays on the stack 2020-03-12 00:17:35 -07:00
Kartik Agaram
0aa7420745 6128 - arrays on the stack 2020-03-11 19:55:45 -07:00