From c4fe34aecd563b0a27c62bdebd9ec1fcb2941806 Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Wed, 24 Jan 2018 22:54:14 +0100 Subject: Hints in README --- README.md | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ca029f6..292cefb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,18 @@ -This is a C compiler for the MAR ([Much-Assembly-Required](https://muchassemblyrequired.com/)) virtual machine, written in C. It is pretty unsophisticated at the moment, but should be able to compile VERY rudimentary C programs, like those in `test/`. Please patch in HWI calls yourself at the moment... +This is a C compiler for the MAR ([Much-Assembly-Required](https://muchassemblyrequired.com/)) virtual machine, written in C. It is pretty unsophisticated at the moment, but should be able to compile VERY rudimentary C programs, like those in `test/`. Note that even though this claims to be a "C compiler" written in C, it is *VERY* far from being able to compile itself. The compiler depends on `flex` and `bison`, and of course a working C compiler (tested with `clang` and `gcc`; the makefile uses `gcc`). Install those, then run `make` to build, and `./ccomp` to run. + +Hints: + +- Don't define any names starting with `__`. Stuff will blow up. +- Asm literals are possible, and the instructions are actually parsed by the compiler. This is to enable inlining variable references and possible optimisations later. Note that because of this, the syntax might be more restricted than you'd like (e.g. `1 + 2` is not allowed). Literals look as follows: + +``` +asm { + mov a, 3 + mov b, 42 + hwi 9 +} +``` -- cgit v1.2.3