summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2024-02-19 22:29:40 -0500
committerKyle Gunger <kgunger12@gmail.com>2024-02-19 22:29:40 -0500
commitbd67baa5e2b9281ffc2b57be5fbd6d9514799994 (patch)
tree2190a6efde56290e967104cbcd92994bbfbcd01c
parentb95702eaa97b578f623610e3f8695a5174233e30 (diff)
Fix for array deref
-rw-r--r--compiler.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler.c b/compiler.c
index c31e9ae..682084e 100644
--- a/compiler.c
+++ b/compiler.c
@@ -807,7 +807,11 @@ void var_op_dereference(CompData *out, Variable *store, Variable *from) {
if (from->location < 1 || from->ptr_chain.count > 1) {
// Generate initial move (from -> rsi)
- vect_push_string(&out->text, "\tmov rsi, ");
+ if (_var_ptr_type(from) > 0)
+ vect_push_string(&out->text, "\tlea rsi, ");
+ else
+ vect_push_string(&out->text, "\tmov rsi, ");
+
if (from->location == LOC_DATA || from->location == LOC_STCK)
vect_push_string(&out->text, PREFIXES[7]);