aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2007-07-03 12:53:00 +0000
committerludwig <ludwig@edf5b092-35ff-0310-97b2-ce42778d08ea>2007-07-03 12:53:00 +0000
commitbf8bdd7c0c0cd4d085aedf70d30a902b5ff1e498 (patch)
treecd3a8d7386200bb051d0ada0e5d127020e3546c4
parentf52dd64512014eebd84effe237f71bae8e70e8f3 (diff)
downloadioquake3-aero-bf8bdd7c0c0cd4d085aedf70d30a902b5ff1e498.tar.gz
ioquake3-aero-bf8bdd7c0c0cd4d085aedf70d30a902b5ff1e498.zip
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
-rw-r--r--code/qcommon/vm_x86_64.c15
1 files 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)