void codegen_setreal(Item* item, double val);
void codegen_setstr(Item* item, char* val);
+void codegen_var(char* name, Type* type);
void codegen_main(char* modname);
void codegen_startproc(char* name, long long localsz);
void codegen_endproc(void);
Type BoolType = {
.form = FORM_BOOL,
- .size = sizeof(int)
+ .size = sizeof(bool)
};
Type IntType = {
.form = FORM_INT,
- .size = sizeof(int)
+ .size = sizeof(long)
};
Type RealType = {
}
}
+void codegen_var(char* name, Type* type)
+{
+ if (type->form == FORM_BOOL || type->form == FORM_INT)
+ {
+ printf(".data\n");
+ printf("%s:\n", name);
+ printf(" .zero %d\n\n", type->size);
+ }
+ else if (type->form == FORM_REAL)
+ {
+ }
+ else
+ {
+ assert(!"not supported");
+ }
+}
+
void codegen_main(char* modname)
{
codegen_startproc("main", 0);
// op_l (OP_CALL, modname);
printf(" call %s\n", modname);
+ printf(" xor %%rax, %%rax\n");
codegen_endproc();
}