Mercurial > repos > blastem
diff gen_x86.c @ 901:dc71e32091d8
Adjust stack before pushing arguments. Fixes new stack alignment code on 32-bit targets
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 27 Nov 2015 10:48:13 -0800 |
parents | 07bfbbbb4b2e |
children | cd6048e0397b |
line wrap: on
line diff
--- a/gen_x86.c Fri Nov 27 10:47:35 2015 -0800 +++ b/gen_x86.c Fri Nov 27 10:48:13 2015 -0800 @@ -2111,18 +2111,18 @@ #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; }