Fix rsp not being escaped properly in the Win32 GAS ASM generator

This commit is contained in:
Curle 2023-04-23 19:20:09 +01:00
parent 4d5fd36390
commit 09af190aa9
3 changed files with 4 additions and 3 deletions

View File

@ -702,13 +702,13 @@ static int AsCall(struct SymbolTableEntry* Entry, int Args) {
printf("\t\t\tFunction returns into %s\n", Registers[OutRegister]); printf("\t\t\tFunction returns into %s\n", Registers[OutRegister]);
// Allocate shadow space // Allocate shadow space
fprintf(OutputFile, "\taddq\t$-32, %rsp\n"); fprintf(OutputFile, "\taddq\t$-32, %%rsp\n");
fprintf(OutputFile, "\tcall\t%s\n", Entry->Name); fprintf(OutputFile, "\tcall\t%s\n", Entry->Name);
// Deallocate arguments and stack space. // Deallocate arguments and stack space.
if (Args > 4) if (Args > 4)
fprintf(OutputFile, "\taddq\t$%d, %%rsp\n", (8 * (Args - 4)) + 32); fprintf(OutputFile, "\taddq\t$%d, %%rsp\n", (8 * (Args - 4)) + 32);
else else
fprintf(OutputFile, "\taddq\t$32, %rsp\n"); fprintf(OutputFile, "\taddq\t$32, %%rsp\n");
fprintf(OutputFile, "\tmovq\t%%rax, %s\n", Registers[OutRegister]); fprintf(OutputFile, "\tmovq\t%%rax, %s\n", Registers[OutRegister]);

1
tests/print.em Normal file
View File

@ -0,0 +1 @@
int :: printf(char* fmt);

View File

@ -1,4 +1,4 @@
import "print.em" import "tests/print.em"
int :: main () { int :: main () {
printf("%s\r\n", "hi there"); printf("%s\r\n", "hi there");