1/* iX386_64.s -- assembly support. */ 2 3/* 4// QuickThreads -- Threads-building toolkit. 5// Copyright (c) 1993 by David Keppel 6// 7// Permission to use, copy, modify and distribute this software and 8// its documentation for any purpose and without fee is hereby 9// granted, provided that the above copyright notice and this notice 10// appear in all copies. This software is provided as a 11// proof-of-concept and for demonstration purposes; there is no 12// representation about the suitability of this software for any 13// purpose. */ 14 15/* 64-bit Intel Architecture Support 16// written by Andy Goodrich, Forte Design Systms, Inc. */ 17 18/* NOTE: double-labeled `_name' and `name' for System V compatability. */ 19/* NOTE: Mixed C/C++-style comments used. Sorry! */ 20 21 .text 22 .align 2 23 24 .globl _qt_abort 25 .globl qt_abort 26 .globl _qt_block 27 .globl qt_block 28 .globl _qt_blocki 29 .globl qt_blocki 30 .globl _qt_align 31 .globl qt_align 32 33_qt_abort: 34qt_abort: 35_qt_block: 36qt_block: 37_qt_blocki: 38qt_blocki: 39 /* 11 (return address.) */ 40 pushq %rbp /* 10 (push stack frame top.) */ 41 movq %rsp, %rbp /* set new stack frame top. */ 42 /* save registers. */ 43 subq $8, %rsp /* 9 (Stack alignment) */ 44 pushq %r12 /* 8 ... */ 45 pushq %r13 /* 7 ... */ 46 pushq %r14 /* 6 ... */ 47 pushq %r15 /* 5 ... */ 48 pushq %rbx /* 4 ... */ 49 pushq %rcx /* 3 ... (new stack address) */ 50 pushq %rdx /* 2 ... (arg) */ 51 pushq %rdi /* 1 ... (address of save function.) */ 52 pushq %rsi /* 0 ... (cor) */ 53 54 movq %rdi, %rax /* get address of save function. */ 55 movq %rsp, %rdi /* set current stack as save argument. */ 56 movq %rcx, %rsp /* swap stacks. */ 57 movq %rcx, %rbp /* adjust stack frame pointer. */ 58 addq $10*8, %rbp /* ... */ 59 call *%rax /* call function to save stack pointer. */ 60 61 /* restore registers. */ 62 popq %rsi /* ... */ 63 popq %rdi /* ... */ 64 popq %rdx /* ... */ 65 popq %rcx /* ... */ 66 popq %rbx /* ... */ 67 popq %r15 /* restore registers from new stack. */ 68 popq %r14 /* ... */ 69 popq %r13 /* ... */ 70 popq %r12 /* ... */ 71 leave /* unwind stack. */ 72_qt_align: 73qt_align: 74 ret /* return. */ 75