Non-working Quickthreads port
[charm.git] / src / QuickThreads / md / t3e.s
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 ; /* t3e.s -- assembly support. */
15
16         .ident qt$s
17
18 ;       /*
19 ;       ** $16: ptr to function to call once curr is suspended
20 ;       **      and control is on r19's stack.
21 ;       ** $17: 1'th arg to (*$16)(...).
22 ;       ** $18: 2'th arg to (*$16)(...).
23 ;       ** $19: sp of thread to resume.
24 ;       **
25 ;       ** The helper routine returns a value that is passed on as the
26 ;       ** return value from the blocking routine.  Since we don't
27 ;       ** touch r0 between the helper's return and the end of
28 ;       ** function, we get this behavior for free.
29 ;       */
30
31         .extern qt_error
32         
33         .stack 256
34         .psect qt_blocki@code,code,cache
35           
36 qt_blocki::
37         subq r30,80, r30
38         stq r26, 0(r30) 
39         stq  r9, 8(r30)
40         stq r10,16(r30)
41         stq r11,24(r30)
42         stq r12,32(r30)
43         stq r13,40(r30)
44         stq r14,48(r30)
45         stq r15,56(r30)
46         stq r29,64(r30)
47         
48 qt_abort::
49         addq r16,r31, r27
50         addq r30,r31, r16
51         addq r19,r31, r30
52         jsr r26,(r27),0
53
54         ldq r26, 0(r30)
55         ldq  r9, 8(r30)
56         ldq r10,16(r30)
57         ldq r11,24(r30)
58         ldq r12,32(r30)
59         ldq r13,40(r30)
60         ldq r14,48(r30)
61         ldq r15,56(r30)
62         ldq r29,64(r30)
63
64         addq r30,80, r30
65         ret r31,(r26),1 
66         .endp
67
68
69 ;       /*
70 ;       ** Non-varargs thread startup.
71 ;       */
72         .stack 256
73         .psect qt_start@code,code,cache
74 qt_start::      
75         addq r9,r31,  r16
76         addq r10,r31, r17
77         addq r11,r31, r18
78         addq r12,r31, r27
79         jsr r26,(r27),0         
80
81         bsr r26,qt_error        
82
83
84 qt_vstart::     
85
86         addq r9,r31, r16        
87         addq r12,r31, r27       
88         jsr r26,(r27),0         
89
90         ldt f16, 0(r30)
91         ldt f17, 8(r30)
92         ldt f18,16(r30)
93         ldt f19,24(r30)
94         ldt f20,32(r30)
95         ldt f21,40(r30)
96         ldq r16,48(r30) 
97         ldq r17,56(r30)
98         ldq r18,64(r30)
99         ldq r19,72(r30)
100         ldq r20,80(r30)
101         ldq r21,88(r30)
102         addq r30,96,r30
103         addq r11,r31, r27
104         jsr r26,(r27),0         
105
106         addq r9,r31, r16        
107         addq r0,r31, r17        
108         addq r10,r31, r27       
109         jsr r26,(r27),0         
110
111         bsr r26,qt_error
112         .endp
113
114
115 ;       /*
116 ;       ** Save calle-save floating-point regs f2..f9.
117 ;       ** Also save return pc from whomever called us.
118 ;       **
119 ;       ** Return value from `qt_block' is the same as the return from
120 ;       ** `qt_blocki'.  We get that for free since we don't touch r0
121 ;       ** between the return from `qt_blocki' and the return from
122 ;       ** `qt_block'.
123 ;       */
124         .stack 256
125         .psect qt_block@code,code,cache
126 qt_block::      
127         subq r30,80, r30
128         stq r26, 0(r30) 
129         stt f2, 8(r30)
130         stt f3,16(r30)
131         stt f4,24(r30)
132         stt f5,32(r30)
133         stt f6,40(r30)
134         stt f7,48(r30)
135         stt f8,56(r30)
136         stt f9,64(r30)
137
138         bsr r26,qt_blocki
139                                 
140
141         ldq r26, 0(r30)         
142         ldt f2, 8(r30)
143         ldt f3,16(r30)
144         ldt f4,24(r30)
145         ldt f5,32(r30)
146         ldt f6,40(r30)
147         ldt f7,48(r30)
148         ldt f8,56(r30)
149         ldt f9,64(r30)
150
151         addq r30,80, r30        
152         ret r31,(r26),1         
153         .endp
154         .end qt$s