You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.3 KiB

5 years ago
  1. # c2logic
  2. Compiles C code to Mindustry logic. Still in beta, so compiled output may not be fully optimized.
  3. # Installation
  4. `pip install git+https://github.com/SuperStormer/c2logic`
  5. # Usage
  6. Run the command line tool using:
  7. `c2logic filename -O optimization_level`
  8. where `filename` is a string and `optimization_level` is an optional integer
  9. Optimization Level:
  10. 0. completely unoptimized
  11. 1. the default
  12. - modify variables without using a temporary
  13. 2. turns on some potentially unsafe optimizations
  14. - augmented assignment and pre/postincrement/decrement don't modify \_\_rax
  15. - returning from main becomes equivalent to `end`
  16. Locals are rewritten as _<varname>_<func_name>. Globals are unchanged.
  17. Special Variables:
  18. - \_\_rax: similar to x86 rax
  19. - \_\_rbx: stores left hand side of binary ops to avoid clobbering by the right side
  20. - \__retaddr_\*: stores return address of func call
  21. When developing your script, you can include `c2logic/builtins.h` located in the python include directory(location depends on system, mine is at `~/.local/include/python3.8/`)
  22. See [examples](./examples) for API sample usage.
  23. # Documentation
  24. See `include/builtins.h` for API definitions.
  25. # Unsupported Features
  26. - drawing
  27. - getlink
  28. - memory cell read/write
  29. - actual functions
  30. - structs
  31. - enums
  32. Some of these features may be worked around using `asm()`.