2 * QuickThreads -- Threads-building toolkit.
3 * Copyright (c) 1993 by David Keppel
5 * Permission to use, copy, modify and distribute this software and
6 * its documentation for any purpose and without fee is hereby
7 * granted, provided that the above copyright notice and this notice
8 * appear in all copies. This software is provided as a
9 * proof-of-concept and for demonstration purposes; there is no
10 * representation about the suitability of this software for any
24 // Calls to these routines have the signature
26 // void *block (func, arg1, arg2, newsp)
28 // Since the prologue saves 5 registers, nargs, pc, fp, ap, mask, and
29 // a condition handler (at sp+0), the first argument is 40=4*10 bytes
30 // offset from the stack pointer.
35 .word 0x7c0 /* Callee-save mask: 5 registers. */
36 movl 56(sp),r1 /* Get stack pointer of new thread. */
37 movl 52(sp),-(r1) /* Push arg2 */
38 movl 48(sp),-(r1) /* Push arg1 */
39 movl sp,-(r1) /* Push arg0 */
41 movl 44(sp),r0 /* Get helper to call. */
42 movl r1,sp /* Move to new thread's stack. */
43 addl3 sp,$12,fp /* .. including the frame pointer. */
44 calls $3,(r0) /* Call helper. */
49 movl (sp)+,r0 /* Get `only'. */
50 calls $3,(r0) /* Call `only'. */
51 calls $0,_qt_error /* `only' erroniously returned. */
55 movl (sp)+,r10 /* Get `pt'. */
56 movl (sp)+,r9 /* Get `startup'. */
57 movl (sp)+,r8 /* Get `vuserf'. */
58 movl (sp)+,r7 /* Get `cleanup'. */
60 pushl r10 /* Push `qt'. */
61 calls $1,(r9) /* Call `startup', pop `qt' on return. */
63 calls (sp)+,(r8) /* Call user's function. */
65 pushl r0 /* Push `vuserf_retval'. */
66 pushl r10 /* Push `qt'. */
67 calls $2,(r7) /* Call `cleanup', never return. */
69 calls $0,_qt_error /* `cleanup' erroniously returned. */