r1105 - trunk/code/qcommon
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Tue Jul 3 08:53:01 EDT 2007
Author: ludwig
Date: 2007-07-03 08:53:00 -0400 (Tue, 03 Jul 2007)
New Revision: 1105
Modified:
trunk/code/qcommon/vm_x86_64.c
Log:
another attempt to fix the alignment, this time hopfully for real
Modified: trunk/code/qcommon/vm_x86_64.c
===================================================================
--- trunk/code/qcommon/vm_x86_64.c 2007-07-03 08:16:21 UTC (rev 1104)
+++ trunk/code/qcommon/vm_x86_64.c 2007-07-03 12:53:00 UTC (rev 1105)
@@ -539,22 +539,27 @@
emit("push %%r8");
emit("push %%r9");
emit("push %%r10");
- emit("push %%r10"); // align!
+ emit("movq %%rsp, %%rbx"); // we need to align the stack pointer
+ emit("subq $8, %%rbx"); // |
+ emit("andq $127, %%rbx"); // |
+ emit("subq %%rbx, %%rsp"); // <-+
+ emit("push %%rbx");
emit("negl %%eax"); // convert to actual number
emit("decl %%eax");
// first argument already in rdi
emit("movq %%rax, %%rsi"); // second argument in rsi
emit("movq $%lu, %%rax", (unsigned long)callAsmCall);
emit("callq *%%rax");
+ emit("pop %%rbx");
+ emit("addq %%rbx, %%rsp");
emit("pop %%r10");
- emit("pop %%r10");
emit("pop %%r9");
emit("pop %%r8");
emit("pop %%rdi");
emit("pop %%rsi");
// emit("frstor 4(%%rsi)");
emit("addq $4, %%rsi");
- emit("movl %%eax, (%%rsi)");
+ emit("movl %%eax, (%%rsi)"); // store return value
break;
case OP_PUSH:
emit("addq $4, %%rsi");
@@ -991,9 +996,9 @@
" movl %4,%%edi \r\n" \
" movq %2,%%r10 \r\n" \
" movq %3,%%r8 \r\n" \
- " subq $8, %%rsp # fix alignment as call pushes one value \r\n" \
+ " subq $24, %%rsp # fix alignment as call pushes one value \r\n" \
" callq *%%r10 \r\n" \
- " addq $8, %%rsp \r\n" \
+ " addq $24, %%rsp \r\n" \
" movl %%edi, %0 \r\n" \
" movq %%rsi, %1 \r\n" \
: "=m" (programStack), "=m" (opStack)
More information about the quake3-commits
mailing list