vax.s revision 12027
1/*
2 * QuickThreads -- Threads-building toolkit.
3 * Copyright (c) 1993 by David Keppel
4 *
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
11 * purpose.
12 */
13
14	.text
15
16	.globl _qt_abort
17	.globl _qt_block
18	.globl _qt_blocki
19	.globl _qt_start
20	.globl _qt_vstart
21
22
23/*
24// Calls to these routines have the signature
25//
26//	void *block (func, arg1, arg2, newsp)
27//
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.
31*/
32_qt_block:
33_qt_blocki:
34_qt_abort:
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 */
40
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. */
45
46	ret
47
48_qt_start:
49	movl (sp)+,r0		/* Get `only'. */
50	calls $3,(r0)		/* Call `only'. */
51	calls $0,_qt_error	/* `only' erroniously returned. */
52
53
54_qt_vstart:
55	movl (sp)+,r10		/* Get `pt'. */
56	movl (sp)+,r9		/* Get `startup'. */
57	movl (sp)+,r8		/* Get `vuserf'. */
58	movl (sp)+,r7		/* Get `cleanup'. */
59
60	pushl r10		/* Push `qt'. */
61	calls $1,(r9)		/* Call `startup', pop `qt' on return. */
62
63	calls (sp)+,(r8)	/* Call user's function. */
64
65	pushl r0		/* Push `vuserf_retval'. */
66	pushl r10		/* Push `qt'. */
67	calls $2,(r7)		/* Call `cleanup', never return. */
68
69	calls $0,_qt_error	/* `cleanup' erroniously returned. */
70