I'm trying to write a (desperately tiny, simple — I have no idea what I'm doing, let's be real!) compiler in OCaml.
I'd really like to avoid checking any ISO-C code into the project (despite knowing C fairly well; the goal here is to learn and use OCaml exclusively.) Pursuant to this, I need to write a “runtime” for the compiled language in OCaml, compile it separately from the primary project, and then link it against the compiler-itself's output.
Unfortunately, it looks like any external functions — even ones that don't touch any OCaml data-structures / the OCaml heap, are expected to be constructed using OCaml's C macros:
CAMLprim value scheme_entry(value unit) {
int i;
i = 42;
return Val_int(i);
}
This probably isn't an option, if I'm emitting the assembly instructions myself. (At least, not until I learn quite a bit more!)
Is there any way (including hacky ones — this is a personal learning project) to invoke extremely simple functions like the following from OCaml?
_scheme_entry:
movl $42 %eax
ret
For reference, I'm working through Ghuloum's IACC: http://ell.io/tt$ocameel