Mercurial > repos > blastem
comparison 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 |
comparison
equal
deleted
inserted
replaced
900:30efd12b1be1 | 901:dc71e32091d8 |
---|---|
2109 } | 2109 } |
2110 } | 2110 } |
2111 #else | 2111 #else |
2112 #define stack_args num_args | 2112 #define stack_args num_args |
2113 #endif | 2113 #endif |
2114 for (int i = stack_args -1; i >= 0; i--) | 2114 uint32_t stack_off_call = code->stack_off + sizeof(void *) * (stack_args + 1); |
2115 { | |
2116 push_r(code, arg_arr[i]); | |
2117 } | |
2118 uint32_t stack_off_call = code->stack_off + sizeof(void *); | |
2119 uint32_t adjust = 0; | 2115 uint32_t adjust = 0; |
2120 if (stack_off_call & 0xF) { | 2116 if (stack_off_call & 0xF) { |
2121 adjust = 16 - (stack_off_call & 0xF); | 2117 adjust = 16 - (stack_off_call & 0xF); |
2122 sub_ir(code, adjust, RSP, SZ_PTR); | 2118 sub_ir(code, adjust, RSP, SZ_PTR); |
2123 code->stack_off += adjust; | 2119 code->stack_off += adjust; |
2124 } | 2120 } |
2125 | 2121 for (int i = stack_args -1; i >= 0; i--) |
2122 { | |
2123 push_r(code, arg_arr[i]); | |
2124 } | |
2125 | |
2126 return stack_args * sizeof(void *) + adjust; | 2126 return stack_args * sizeof(void *) + adjust; |
2127 } | 2127 } |
2128 | 2128 |
2129 void call_args(code_info *code, code_ptr fun, uint32_t num_args, ...) | 2129 void call_args(code_info *code, code_ptr fun, uint32_t num_args, ...) |
2130 { | 2130 { |