@@ -327,30 +327,36 @@ class BackendLinux86 : CompilerBackend {
327327 }
328328 else if (word.type == WordType.C) {
329329 if (word.params.length >= 1 ) {
330- output ~= " sub r15, 8\n " ;
331- output ~= " mov rdi, [r15]\n " ;
330+ output ~= format(
331+ " mov rdi, [r15 - %d]\n " , word.params.length * 8
332+ );
332333 }
333334 if (word.params.length >= 2 ) {
334- output ~= " sub r15, 8\n " ;
335- output ~= " mov rsi, [r15]\n " ;
335+ output ~= format(
336+ " mov rsi, [r15 - %d]\n " , (word.params.length - 1 ) * 8
337+ );
336338 }
337339 if (word.params.length >= 3 ) {
338- output ~= " sub r15, 8\n " ;
339- output ~= " mov rdx, [r15]\n " ;
340+ output ~= format(
341+ " mov rdx, [r15 - %d]\n " , (word.params.length - 2 ) * 8
342+ );
340343 }
341344 if (word.params.length >= 4 ) {
342- output ~= " sub r15, 8\n " ;
343- output ~= " mov rcx, [r15]\n " ;
345+ output ~= format(
346+ " mov rcx, [r15 - %d]\n " , (word.params.length - 3 ) * 8
347+ );
344348 }
345349 if (word.params.length >= 5 ) {
346- output ~= " sub r15, 8\n " ;
347- output ~= " mov r8, [r15]\n " ;
350+ output ~= format(
351+ " mov r8, [r15 - %d]\n " , (word.params.length - 4 ) * 8
352+ );
348353 }
349354 if (word.params.length >= 6 ) {
350- output ~= " sub r15, 8\n " ;
351- output ~= " mov r9, [r15]\n " ;
355+ output ~= format(
356+ " mov r9, [r15 - %d]\n " , (word.params.length - 5 ) * 8
357+ );
352358 }
353-
359+ output ~= format( " sub r15, %d \n " , word.params.length * 8 );
354360
355361 output ~= format(" call %s\n " , node.name);
356362
0 commit comments