diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2024-02-04 03:36:37 -0500 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2024-02-04 03:36:37 -0500 |
commit | 6c214178bbdd04a67f045dd8c3e29f3a98502115 (patch) | |
tree | cad89ed02c0788712ea616a1cf4e787d356ee5a4 /compiler.c | |
parent | 3bf3e5d1ec45838d2a839d35ce34fd93a522e874 (diff) |
remove unused funcs
Diffstat (limited to 'compiler.c')
-rw-r--r-- | compiler.c | 121 |
1 files changed, 2 insertions, 119 deletions
@@ -111,14 +111,7 @@ void vect_push_string(Vector *v, char *str) { } void vect_push_free_string(Vector *v, char *str) { - if (v->_el_sz != sizeof(char)) { - return; - } - - for (size_t i = 0; str[i] != 0; i++) { - vect_insert(v, v->count, str + i); - } - + vect_push_string(v, str); free(str); } @@ -498,45 +491,6 @@ void var_end(Variable *v) { // Variable operations -Vector _reg_by_id(int id) { - Vector out = vect_init(sizeof(char)); - - switch (id) { - case 0: - vect_push_string(&out, "ax"); - break; - case 1: - vect_push_string(&out, "bx"); - break; - case 2: - vect_push_string(&out, "cx"); - break; - case 3: - vect_push_string(&out, "dx"); - break; - case 4: - vect_push_string(&out, "si"); - break; - case 5: - vect_push_string(&out, "di"); - break; - case 6: - vect_push_string(&out, "sp"); - break; - case 7: - vect_push_string(&out, "bp"); - break; - } - - if(id > 7) { - char *num = int_to_str(id); - vect_push_string(&out, num); - free(num); - } - - return out; -} - // Valid prefixes for fasm, take size of data - 1 = index of prefix. char *PREFIXES[] = { "byte ", @@ -549,75 +503,6 @@ char *PREFIXES[] = { "qword " }; -char *_reg_by_id_size(int id, int size, bool address) { - Vector reg = _reg_by_id(id); - // If address, prefix with the desired size (byte, word, dword, or qword respectively) - Vector prefix = vect_init(sizeof(char)); - - if(address) { - switch(size) { - case 1: - case 2: - case 4: - case 8: - vect_push_string(&prefix, PREFIXES[size - 1]); - break; - } - size = 8; - } - - if(id > 7) { - char pref = 'r'; - vect_insert(®, 0, &pref); - } - - switch(size) { - case 1: - if(id > 7) { - char suff = 'b'; - vect_push(®, &suff); - } else if (id > 3) { - char suff = 'l'; - vect_push(®, &suff); - } else { - ((char*)reg.data)[1] = 'l'; - } - break; - case 2: - if(id > 7) { - char suff = 'w'; - vect_push(®, &suff); - } - break; - case 4: - if (id > 7) { - char suff = 'd'; - vect_push(®, &suff); - } else { - char pref = 'e'; - vect_insert(®, 0, &pref); - } - break; - case 8: - if (id < 8) { - char pref = 'r'; - vect_insert(®, 0, &pref); - } - } - - if (address) { - char brack = '['; - vect_insert(®, 0, &brack); - brack = ']'; - vect_push(®, &brack); - } - - vect_push_string(&prefix, vect_as_string(®)); - vect_end(®); - - return vect_as_string(&prefix); -} - /// Remember to free! char *_gen_address(char *prefix, char *base, char *offset, int mult, int add) { Vector out = vect_init(sizeof(char)); @@ -841,10 +726,8 @@ void var_op_dereference(CompData *out, Variable *store, Variable *from) { vect_push_string(&out->text, "\tmov rsi, "); if (from->location < 1) vect_push_string(&out->text, PREFIXES[7]); - char *addr = _op_get_location(from); - vect_push_string(&out->text, addr); - free(addr); + vect_push_free_string(&out->text, _op_get_location(from)); vect_push_string(&out->text, "; Move for dereference\n"); // Keep de-referencing until we reach the pointer (or ptr_chain bottoms out). |