From bd67baa5e2b9281ffc2b57be5fbd6d9514799994 Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Mon, 19 Feb 2024 22:29:40 -0500 Subject: Fix for array deref --- compiler.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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]); -- cgit v1.2.3