summaryrefslogtreecommitdiff
path: root/gen_x86.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2015-11-27 10:48:13 -0800
committerMichael Pavone <pavone@retrodev.com>2015-11-27 10:48:13 -0800
commit3912d03d0036c899484af331f38f474c343de743 (patch)
treea37e4c3b0df72b3f9b637d23b9f9a8b59b213c4c /gen_x86.c
parent76e43f2347ea882f95666fcb0ac23d33282ba922 (diff)
Adjust stack before pushing arguments. Fixes new stack alignment code on 32-bit targets
Diffstat (limited to 'gen_x86.c')
-rw-r--r--gen_x86.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/gen_x86.c b/gen_x86.c
index cfc826a..fec5790 100644
--- a/gen_x86.c
+++ b/gen_x86.c
@@ -2111,18 +2111,18 @@ uint32_t prep_args(code_info *code, uint32_t num_args, va_list args)
#else
#define stack_args num_args
#endif
- for (int i = stack_args -1; i >= 0; i--)
- {
- push_r(code, arg_arr[i]);
- }
- uint32_t stack_off_call = code->stack_off + sizeof(void *);
+ uint32_t stack_off_call = code->stack_off + sizeof(void *) * (stack_args + 1);
uint32_t adjust = 0;
if (stack_off_call & 0xF) {
adjust = 16 - (stack_off_call & 0xF);
sub_ir(code, adjust, RSP, SZ_PTR);
code->stack_off += adjust;
}
-
+ for (int i = stack_args -1; i >= 0; i--)
+ {
+ push_r(code, arg_arr[i]);
+ }
+
return stack_args * sizeof(void *) + adjust;
}