From bf8bdd7c0c0cd4d085aedf70d30a902b5ff1e498 Mon Sep 17 00:00:00 2001 From: ludwig Date: Tue, 3 Jul 2007 12:53:00 +0000 Subject: another attempt to fix the alignment, this time hopfully for real git-svn-id: svn://svn.icculus.org/quake3/trunk@1105 edf5b092-35ff-0310-97b2-ce42778d08ea --- code/qcommon/vm_x86_64.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/code/qcommon/vm_x86_64.c b/code/qcommon/vm_x86_64.c index b549c0e..1d9480c 100644 --- a/code/qcommon/vm_x86_64.c +++ b/code/qcommon/vm_x86_64.c @@ -539,14 +539,19 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) { 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 %%r10"); + emit("pop %%rbx"); + emit("addq %%rbx, %%rsp"); emit("pop %%r10"); emit("pop %%r9"); emit("pop %%r8"); @@ -554,7 +559,7 @@ void VM_Compile( vm_t *vm, vmHeader_t *header ) { 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 @@ int VM_CallCompiled( vm_t *vm, int *args ) { " 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) -- cgit v1.2.3