axp.s 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. # axp.s -- assembly support.
  14. .text
  15. .align 4
  16. .file 2 "axp.s"
  17. .globl qt_block
  18. .globl qt_blocki
  19. .globl qt_abort
  20. .globl qt_start
  21. .globl qt_vstart
  22. #
  23. # $16: ptr to function to call once curr is suspended
  24. # and control is on r19's stack.
  25. # $17: 1'th arg to (*$16)(...).
  26. # $18: 2'th arg to (*$16)(...).
  27. # $19: sp of thread to resume.
  28. #
  29. # The helper routine returns a value that is passed on as the
  30. # return value from the blocking routine. Since we don't
  31. # touch r0 between the helper's return and the end of
  32. # function, we get this behavior for free.
  33. #
  34. .ent qt_blocki
  35. qt_blocki:
  36. subq $30,80, $30 # Allocate save area.
  37. stq $26, 0($30) # Save registers.
  38. stq $9, 8($30)
  39. stq $10,16($30)
  40. stq $11,24($30)
  41. stq $12,32($30)
  42. stq $13,40($30)
  43. stq $14,48($30)
  44. stq $15,56($30)
  45. stq $29,64($30)
  46. .end qt_blocki
  47. .ent qt_abort
  48. qt_abort:
  49. addq $16,$31, $27 # Put argument function in PV.
  50. addq $30,$31, $16 # Save stack ptr in outgoing arg.
  51. addq $19,$31, $30 # Set new stack pointer.
  52. jsr $26,($27),0 # Call helper function.
  53. ldq $26, 0($30) # Restore registers.
  54. ldq $9, 8($30)
  55. ldq $10,16($30)
  56. ldq $11,24($30)
  57. ldq $12,32($30)
  58. ldq $13,40($30)
  59. ldq $14,48($30)
  60. ldq $15,56($30)
  61. ldq $29,64($30)
  62. addq $30,80, $30 # Deallocate save area.
  63. ret $31,($26),1 # Return, predict===RET.
  64. .end qt_abort
  65. #
  66. # Non-varargs thread startup.
  67. #
  68. .ent qt_start
  69. qt_start:
  70. addq $9,$31, $16 # Load up `qu'.
  71. addq $10,$31, $17 # ... user function's `pt'.
  72. addq $11,$31, $18 # ... user function's `userf'.
  73. addq $12,$31, $27 # ... set procedure value to `only'.
  74. jsr $26,($27),0 # Call `only'.
  75. jsr $26,qt_error # `only' erroniously returned.
  76. .end qt_start
  77. .ent qt_vstart
  78. qt_vstart:
  79. # Call startup function.
  80. addq $9,$31, $16 # Arg0 to `startup'.
  81. addq $12,$31, $27 # Set procedure value.
  82. jsr $26,($27),0 # Call `startup'.
  83. # Call user function.
  84. ldt $f16, 0($30) # Load fp arg regs.
  85. ldt $f17, 8($30)
  86. ldt $f18,16($30)
  87. ldt $f19,24($30)
  88. ldt $f20,32($30)
  89. ldt $f21,40($30)
  90. ldq $16,48($30) # And integer arg regs.
  91. ldq $17,56($30)
  92. ldq $18,64($30)
  93. ldq $19,72($30)
  94. ldq $20,80($30)
  95. ldq $21,88($30)
  96. addq $30,96, $30 # Pop 6*2*8 saved arg regs.
  97. addq $11,$31, $27 # Set procedure value.
  98. jsr $26,($27),0 # Call `vuserf'.
  99. # Call cleanup.
  100. addq $9,$31, $16 # Arg0 to `cleanup'.
  101. addq $0,$31, $17 # Users's return value is arg1.
  102. addq $10,$31, $27 # Set procedure value.
  103. jsr $26,($27),0 # Call `cleanup'.
  104. jsr $26,qt_error # Cleanup erroniously returned.
  105. .end qt_start
  106. #
  107. # Save calle-save floating-point regs $f2..$f9.
  108. # Also save return pc from whomever called us.
  109. #
  110. # Return value from `qt_block' is the same as the return from
  111. # `qt_blocki'. We get that for free since we don't touch $0
  112. # between the return from `qt_blocki' and the return from
  113. # `qt_block'.
  114. #
  115. .ent qt_block
  116. qt_block:
  117. subq $30,80, $30 # Allocate a save space.
  118. stq $26, 0($30) # Save registers.
  119. stt $f2, 8($30)
  120. stt $f3,16($30)
  121. stt $f4,24($30)
  122. stt $f5,32($30)
  123. stt $f6,40($30)
  124. stt $f7,48($30)
  125. stt $f8,56($30)
  126. stt $f9,64($30)
  127. jsr $26,qt_blocki # Call helper.
  128. # .. who will also restore $gp.
  129. ldq $26, 0($30) # restore registers.
  130. ldt $f2, 8($30)
  131. ldt $f3,16($30)
  132. ldt $f4,24($30)
  133. ldt $f5,32($30)
  134. ldt $f6,40($30)
  135. ldt $f7,48($30)
  136. ldt $f8,56($30)
  137. ldt $f9,64($30)
  138. addq $30,80, $30 # Deallcate save space.
  139. ret $31,($26),1 # Return, predict===RET.
  140. .end qt_block