diff --git a/source/backends/rm86.d b/source/backends/rm86.d index caee63b..eb57fb2 100644 --- a/source/backends/rm86.d +++ b/source/backends/rm86.d @@ -320,7 +320,7 @@ class BackendRM86 : CompilerBackend { output ~= format("jne __func__%s\n", Sanitise("__rm86_exception")); } else { - output ~= "mov si, di\n"; + output ~= "mov si, di\n"; CompileReturn(node); } } diff --git a/source/backends/uxn.d b/source/backends/uxn.d index 4068e82..5905bf7 100644 --- a/source/backends/uxn.d +++ b/source/backends/uxn.d @@ -275,7 +275,7 @@ class BackendUXN : CompilerBackend { output ~= format(";func__%s JCN2\n", Sanitise("__uxn_exception")); } else { - output ~= ".temp LDZ .System/wst DEO\n"; + output ~= ".temp LDZ .System/wst DEO\n"; CompileReturn(node); } } diff --git a/source/backends/x86_64.d b/source/backends/x86_64.d index ef3ca84..bf36615 100644 --- a/source/backends/x86_64.d +++ b/source/backends/x86_64.d @@ -510,11 +510,24 @@ class BackendX86_64 : CompilerBackend { "mov r9, [r15 - %d]\n", (word.params.length - 5) * 8 ); } - output ~= format("sub r15, %d\n", word.params.length * 8); - // TODO: support more than 6 parameters + // align stack pointer + output ~= "mov rbp, rsp\n"; + output ~= "and rsp, 0xFFFFFFFFFFFFFFF0\n"; + + if (word.params.length > 6) { + // push parameters + foreach_reverse (i ; 6 .. word.params.length) { + output ~= format( + "push qword [r15 - %d]\n", (word.params.length - i) * 8 + ); + } + } + // remove parameters + output ~= format("sub r15, %d\n", word.params.length * 8); output ~= format("call %s\n", ExternSymbol(word.symbolName)); + output ~= "mov rsp, rbp\n"; if (!word.isVoid) { output ~= "mov [r15], rax\n";