diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2024-02-13 16:38:10 -0500 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2024-02-13 16:38:10 -0500 |
commit | d7b801fb71b166699e58dbbe2b502f406d1a2038 (patch) | |
tree | 36f717588a8281e90a722ea9e9eb265d82531b1d | |
parent | da46d46b9403f1d5ef1f1d355bb3af25187a944d (diff) |
reg gen fix
-rw-r--r-- | compiler.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -300,7 +300,7 @@ void cdat_add(CompData *a, CompData *b) { } void cdat_write_to_file(CompData *cdat, FILE *fout) { - fprintf(fout, "format ELF64\n%s\n", vect_as_string(&(cdat->header))); + fprintf(fout, "\n%s\n", vect_as_string(&(cdat->header))); fprintf(fout, "%s\n", vect_as_string(&(cdat->data))); fprintf(fout, "%s\n", vect_as_string(&(cdat->text))); fflush(fout); @@ -607,9 +607,11 @@ char *_op_get_register(int reg, int size) { switch(size) { case 1: case 2: - break; + if (reg < 9) + break; case 4: - add = 'e'; + if (reg < 9) + add = 'e'; case 8: vect_push(&out, &add); break; @@ -637,14 +639,18 @@ char *_op_get_register(int reg, int size) { add = 'b'; break; default: + if(reg > 8) { char *tmp = int_to_str(reg - 1); vect_push_string(&out, tmp); free(tmp); } + add = 0; break; } - vect_push(&out, &add); + + if (add > 0) + vect_push(&out, &add); add = 'x'; switch (reg) { |