CPlastane, is a cool C compiler designed with standard compatibility in mind.
Implemented features:
- x86/64 assembler (no linker yet)
Planned features:
- C parser
- LLVM frontend, middleend, backend
auto main() -> int {
string s = "mov DWORD eax, 100\n"
"mov BYTE ah, [eax + ebx * 2 + 128]\n"
"push DWORD [eax]\n"
"ret\n";
// Parse assembly code into a list of syntax structures
vector<mnemo_t> mnemos = assembly::parse::parse(s);
// Assemble syntax into actual x86/64 bytecode
vector<u8> bytes = assembly::assemble(mnemos);
// Execute bytecode from a bytes vector
int n = jit::eval_mc(bytes.data(), bytes.size());
std::cout << n << "\n";
}