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
14 # axp.s -- assembly support.
27 # $16: ptr to function to call once curr is suspended
28 # and control is on r19's stack.
29 # $17: 1'th arg to (*$16)(...).
30 # $18: 2'th arg to (*$16)(...).
31 # $19: sp of thread to resume.
33 # The helper routine returns a value that is passed on as the
34 # return value from the blocking routine. Since we don't
35 # touch r0 between the helper's return and the end of
36 # function, we get this behavior for free.
41 subq $30,80, $30 # Allocate save area.
42 stq $26, 0($30) # Save registers.
54 addq $16,$31, $27 # Put argument function in PV.
55 addq $30,$31, $16 # Save stack ptr in outgoing arg.
56 addq $19,$31, $30 # Set new stack pointer.
57 jsr $26,($27),0 # Call helper function.
59 ldq $26, 0($30) # Restore registers.
69 addq $30,80, $30 # Deallocate save area.
70 ret $31,($26),1 # Return, predict===RET.
75 # Non-varargs thread startup.
79 addq $9,$31, $16 # Load up `qu'.
80 addq $10,$31, $17 # ... user function's `pt'.
81 addq $11,$31, $18 # ... user function's `userf'.
82 addq $12,$31, $27 # ... set procedure value to `only'.
83 jsr $26,($27),0 # Call `only'.
85 jsr $26,qt_error # `only' erroniously returned.
91 # Call startup function.
92 addq $9,$31, $16 # Arg0 to `startup'.
93 addq $12,$31, $27 # Set procedure value.
94 jsr $26,($27),0 # Call `startup'.
97 ldt $f16, 0($30) # Load fp arg regs.
103 ldq $16,48($30) # And integer arg regs.
109 addq $30,96, $30 # Pop 6*2*8 saved arg regs.
110 addq $11,$31, $27 # Set procedure value.
111 jsr $26,($27),0 # Call `vuserf'.
114 addq $9,$31, $16 # Arg0 to `cleanup'.
115 addq $0,$31, $17 # Users's return value is arg1.
116 addq $10,$31, $27 # Set procedure value.
117 jsr $26,($27),0 # Call `cleanup'.
119 jsr $26,qt_error # Cleanup erroniously returned.
124 # Save calle-save floating-point regs $f2..$f9.
125 # Also save return pc from whomever called us.
127 # Return value from `qt_block' is the same as the return from
128 # `qt_blocki'. We get that for free since we don't touch $0
129 # between the return from `qt_blocki' and the return from
134 subq $30,80, $30 # Allocate a save space.
135 stq $26, 0($30) # Save registers.
145 jsr $26,qt_blocki # Call helper.
146 # .. who will also restore $gp.
148 ldq $26, 0($30) # restore registers.
158 addq $30,80, $30 # Deallcate save space.
159 ret $31,($26),1 # Return, predict===RET.