From 14b11511d804e149c02e8163b45e9f4aac81b4de Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Sun, 28 Jan 2024 00:16:11 -0500 Subject: negative offset _gen_address --- compiler.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler.c b/compiler.c index e1b6844..2ee9514 100644 --- a/compiler.c +++ b/compiler.c @@ -619,12 +619,18 @@ char *_gen_address(char *prefix, char *base, char *offset, int mult, int add) { } } - if(add > 0) { - vect_push_string(&out, " + "); + if(add != 0) { + if (add > 0) { + vect_push_string(&out, " + "); + } else { + vect_push_string(&out, " - "); + add = -add; + } char *astr = int_to_str(add); vect_push_string(&out, astr); free(astr); } + vect_push_string(&out, "]"); -- cgit v1.2.3