Compiles C code to Mindustry logic. Still in beta, so compiled output may not be fully optimized. Requirements are the pycparser
package and the C preprocessor (cpp
).
pip install git+https://github.com/SuperStormer/c2logic
Run the command line tool using:
c2logic filename -O optimization_level
where filename
is a string and optimization_level
is an optional integer.
Optimization Level:
__rax
end
Locals are rewritten as _<varname>_<func_name>
. Globals are unchanged.
Special Variables:
__rax
: similar to x86 rax__rbx
: stores left hand side of binary ops to avoid clobbering by the right side__retaddr__<func_name>
: stores return address of func callWhen writing your code, you must include c2logic/builtins.h
, which is located in the python include directory (location depends on system, mine is at ~/.local/include/python3.8/
).
A quick way to find this is python3 -c "from c2logic.compiler import get_include_path; print(get_include_path())"
(use python
if you are using windows).
See include/builtins.h for API definitions and examples for API sample usage.