#include "compiler.h" #include "types.h" #include "include/estr.h" char* compileGroundProgram(GroundProgram* program) { Estr start = CREATE_ESTR("global _start\nsection .text\n_start:\n"); Estr data = CREATE_ESTR("section .rodata\n"); for (size_t i = 0; i < program->size; i++) { switch (program->instructions[i].type) { case END: { APPEND_ESTR(start, " mov rax, 60\n"); APPEND_ESTR(start, " mov rdi, 0\n"); APPEND_ESTR(start, " syscall\n"); break; } default: { printf("no\n"); exit(1); } } } Estr complete = CREATE_ESTR(""); APPEND_ESTR(complete, start.str); APPEND_ESTR(complete, data.str) return complete.str; }