summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTing-Wei Lan <lantw44@gmail.com>2016-01-21 16:51:20 +0800
committerTing-Wei Lan <lantw44@gmail.com>2016-01-21 16:51:20 +0800
commit17d17e0ee801ba40cd8f83d29422449001d19941 (patch)
tree9bdcc42cbbc104cdbc924a82cd56dc2f2e212203
parentacf881315dd1052c5e2617f0c4dd57a7b54fb077 (diff)
downloadcompiler2015-17d17e0ee801ba40cd8f83d29422449001d19941.tar
compiler2015-17d17e0ee801ba40cd8f83d29422449001d19941.tar.gz
compiler2015-17d17e0ee801ba40cd8f83d29422449001d19941.tar.bz2
compiler2015-17d17e0ee801ba40cd8f83d29422449001d19941.tar.lz
compiler2015-17d17e0ee801ba40cd8f83d29422449001d19941.tar.xz
compiler2015-17d17e0ee801ba40cd8f83d29422449001d19941.tar.zst
compiler2015-17d17e0ee801ba40cd8f83d29422449001d19941.zip
Fix stack restoration after function calls
-rw-r--r--src/code-generation.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/code-generation.c b/src/code-generation.c
index c56f523..a96aaf6 100644
--- a/src/code-generation.c
+++ b/src/code-generation.c
@@ -534,7 +534,7 @@ static void call_function(CcmmcAst *id, CcmmcState *state,
if (call_param_count > 8)
fprintf(state->asm_output,
"\tadd\tsp, sp, %zu\n",
- call_param_count * 8);
+ (call_param_count - 8) * 8);
ccmmc_register_caller_load(state->reg_pool);
ccmmc_register_load_arguments(state->reg_pool, stored_param_count);
for (i = 0; i < call_param_count; i++)