diff options
author | Michael Pavone <pavone@retrodev.com> | 2015-11-27 10:48:13 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2015-11-27 10:48:13 -0800 |
commit | 3912d03d0036c899484af331f38f474c343de743 (patch) | |
tree | a37e4c3b0df72b3f9b637d23b9f9a8b59b213c4c /gen_x86.c | |
parent | 76e43f2347ea882f95666fcb0ac23d33282ba922 (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.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -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; } |