simon816 / Command-Block-Assembly

Compile high-level code into Minecraft commands
https://www.simon816.com/minecraft/assembler
MIT License
271 stars 29 forks source link

Potential Binutils? #9

Closed chorman0773 closed 5 years ago

chorman0773 commented 5 years ago

I was wondering if it may be possible to write a full set of binutils for this (Basically have a ld which does some checks and that's it, and as which is a port of this, or a thin-wrapper arround this), which would basically enable people to use full gcc. It would take some more work than just this, but it would be a start.

simon816 commented 5 years ago

Are you thinking it'd be possible to use the real gcc and link the object files to command block assembly? That would not be feasible because object files generated by gcc are compiled for an architecture known to gcc (e.g. x86_64) and it'd be a lot of work to translate the output to command block assembly's language.

Instead, CBA will provide the tools needed for its ecosystem, currently there's an assembler and a compiler, I may create a linker in the future (currently the "linking" step is performed internally by the assembler)

chorman0773 commented 5 years ago

Well it would be possible to substitue the internal assembler with cba/as, then write some backend code to the assembly. Its theoretically possible, but as you noted, quite a bit of work. The main things needed are of course as and ld.

simon816 commented 5 years ago

If I were to go that route then I'd write a backend for LLVM, which is something I might do. I already designed Command IR which is what I will be using going forward.