Minor fixes for the linux assembler

This commit is contained in:
Curle 2023-12-07 22:33:51 +00:00
parent 84c5c9f4f2
commit c11e0792f4
3 changed files with 11 additions and 12 deletions

View File

@ -734,6 +734,8 @@ static void AsGlobalSymbol(struct SymbolTableEntry* Entry) {
fprintf(OutputFile,"\t.globl\t%s\n", Entry->Name);
fprintf(OutputFile, "%s:\n", Entry->Name);
printf("%s, %d\n", Entry->Name, Entry->Length);
for (i = 0; i < Entry->Length; i++) {
init = 0;
if (Entry->InitialValues != NULL)
@ -780,13 +782,10 @@ static int AsCall(struct SymbolTableEntry* Entry, int Args) {
printf("\t\t\tFunction returns into %s\n", Registers[OutRegister]);
// Allocate shadow space
fprintf(OutputFile, "\taddq\t$-32, %%rsp\n");
fprintf(OutputFile, "\tcall\t%s\n", Entry->Name);
// Deallocate arguments and stack space.
if (Args > 4)
fprintf(OutputFile, "\taddq\t$%d, %%rsp\n", (8 * (Args - 4)) + 32);
else
fprintf(OutputFile, "\taddq\t$32, %%rsp\n");
if (Args > 6)
fprintf(OutputFile, "\taddq\t$%d, %%rsp\n", 8 * (Args - 6));
fprintf(OutputFile, "\tmovq\t%%rax, %s\n", Registers[OutRegister]);
@ -1020,11 +1019,11 @@ static void AsFunctionPreamble(struct SymbolTableEntry* Entry) {
if (ParamCount > 6) { // We only have 6 argument registers
Param->SinkOffset = ParamOffset;
ParamOffset += 8;
} else {
Entry->SinkOffset = AsCalcOffset(Param->Type);
AsStrLocalVar(Param, ParamReg--);
}
Entry->SinkOffset = AsCalcOffset(Param->Type);
AsStrLocalVar(Param, ParamReg--);
}
}
// If we have more parameters, move them to the stack
for (Local = Locals; Local != NULL; Local = Local->NextSymbol) {
@ -1032,7 +1031,7 @@ static void AsFunctionPreamble(struct SymbolTableEntry* Entry) {
}
// With all the parameters on the stack, we can allocate the shadow space
StackFrameOffset = ((LocalVarOffset + 31) & ~31);
StackFrameOffset = ((LocalVarOffset + 15) & ~16);
fprintf(OutputFile,
"\taddq\t$%d, %%rsp\n", -StackFrameOffset);

View File

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

View File

@ -1,4 +1,4 @@
import "tests/print.em"
import "import/defs.eh"
int stuff[] = { 5, 7, 9 };