Skip to content

Commit 54a1d76

Browse files
committed
fix signed 32 bit integer pushing because i accidentally broke it
1 parent 2377c68 commit 54a1d76

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

source/backends/x86_64.d

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -554,8 +554,13 @@ class BackendX86_64 : CompilerBackend {
554554
break;
555555
}
556556
case 4: {
557-
output ~= "xor rax, rax\n";
558-
output ~= format("mov eax, [rbx + %d]\n", offset);
557+
if (op == 's') {
558+
output ~= format("movsxd rax, $(DWORD) [rbx + %d]\n", offset);
559+
}
560+
else {
561+
output ~= "xor rax, rax\n";
562+
output ~= format("mov eax, [rbx + %d]\n", offset);
563+
}
559564
break;
560565
}
561566
case 8: output ~= format("mov rax, [rbx + %d]\n", offset); break;
@@ -573,8 +578,15 @@ class BackendX86_64 : CompilerBackend {
573578
break;
574579
}
575580
case 4: {
576-
output ~= "xor rax, rax\n";
577-
output ~= format("mov eax, [%s + %d]\n", symbol, offset);
581+
if (op == 's') {
582+
output ~= format(
583+
"movsxd rax, $(DWORD) [%s + %d]\n", symbol, offset
584+
);
585+
}
586+
else {
587+
output ~= "xor rax, rax\n";
588+
output ~= format("mov eax, [%s + %d]\n", symbol, offset);
589+
}
578590
break;
579591
}
580592
case 8: output ~= format("mov rax, [%s + %d]\n", symbol, offset); break;

0 commit comments

Comments
 (0)