summaryrefslogtreecommitdiff
path: root/compiler.c
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2024-01-28 00:16:11 -0500
committerKyle Gunger <kgunger12@gmail.com>2024-01-28 00:16:11 -0500
commit14b11511d804e149c02e8163b45e9f4aac81b4de (patch)
treef6cb8c10a6864abb3b582568b323821ea8d5d672 /compiler.c
parentdc153016a42091d1f4edfa2c2cbe8656eadc8596 (diff)
negative offset _gen_address
Diffstat (limited to 'compiler.c')
-rw-r--r--compiler.c10
1 files 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, "]");