par_misc.e 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #
  2. ;
  3. ; (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. ; See the copyright notice in the ACK home directory, in the file "Copyright".
  5. ;
  6. ;
  7. ; Module: coroutine primitives
  8. ; Author: Kees Bot, Edwin Scheffer, Ceriel Jacobs
  9. ; Version: $Id$
  10. ;
  11. mes 2,EM_WSIZE,EM_PSIZE
  12. ; topsize takes care of two things:
  13. ; - given a stack-break,
  14. ; it computes the size of the chunk of memory needed to save the stack;
  15. ; - also, if this stack-break = 0, it creates one, assuming that caller is
  16. ; the stack-break.
  17. ;
  18. ; This implementation assumes a continuous stack growing downwards
  19. exp $topsize
  20. #ifdef __sparc
  21. inp $topsize2
  22. pro $topsize, 0
  23. mes 11
  24. zer EM_PSIZE
  25. lal 0
  26. loi EM_PSIZE
  27. cal $topsize2
  28. asp 2*EM_PSIZE
  29. lfr EM_WSIZE
  30. ret EM_WSIZE
  31. end 0
  32. pro $topsize2, 3*EM_WSIZE+3*EM_PSIZE
  33. #else
  34. pro $topsize, 3*EM_WSIZE+3*EM_PSIZE
  35. #endif
  36. ; local space for line-number, ignoremask, filename, stack-break, size,
  37. ; and stack-pointer (see the topsave routine)
  38. mes 11
  39. lal 0
  40. loi EM_PSIZE
  41. loi EM_PSIZE ; stack-break or 0
  42. zer EM_PSIZE
  43. cmp
  44. zne *1
  45. lxl 0
  46. dch ; local base of caller
  47. #ifdef __sparc
  48. dch ; because of the extra layer
  49. #endif
  50. lal 0
  51. loi EM_PSIZE
  52. sti EM_PSIZE
  53. 1
  54. lal 0
  55. loi EM_PSIZE
  56. loi EM_PSIZE
  57. lpb ; convert this local base to an argument base.
  58. ; An implementation of a sort of "topsize" EM
  59. ; instruction should take a local base, and save
  60. ; the whole frame.
  61. lor 1 ; stack-break SP
  62. sbs EM_WSIZE ; stack-break-SP
  63. ret EM_WSIZE ; return size of block to be saved
  64. end 3*EM_WSIZE+3*EM_PSIZE
  65. exp $topsave
  66. #ifdef __sparc
  67. inp $topsave2
  68. pro $topsave,0
  69. mes 11
  70. lal 0
  71. loi 2*EM_PSIZE
  72. cal $topsave2
  73. asp 2*EM_PSIZE
  74. lfr EM_WSIZE
  75. ret EM_WSIZE
  76. end 0
  77. pro $topsave2,0
  78. #else
  79. pro $topsave, 0
  80. #endif
  81. mes 11
  82. loe 0
  83. lae 4 ; load line number and file name
  84. loi EM_PSIZE
  85. lim ; ignore mask
  86. lor 0 ; LB
  87. lal 0
  88. loi EM_PSIZE ; stack-break
  89. lpb
  90. lor 1
  91. sbs EM_WSIZE
  92. loc EM_WSIZE
  93. adu EM_WSIZE ; gives size
  94. dup EM_WSIZE
  95. stl 0 ; save size
  96. lor 1 ; SP (the SP BEFORE pushing)
  97. lor 1 ; SP (address of stack top to save)
  98. lal EM_PSIZE ; area
  99. loi EM_PSIZE
  100. lol 0 ; size
  101. bls EM_WSIZE ; move whole block
  102. asp 3*EM_PSIZE+3*EM_WSIZE ; remove the lot from the stack
  103. loc 1
  104. ret EM_WSIZE ; return 1
  105. end 0
  106. sv
  107. bss EM_PSIZE,0,0
  108. exp $topload
  109. #ifdef __sparc
  110. inp $topload1
  111. pro $topload,0
  112. lal 0
  113. loi EM_PSIZE
  114. cal $topload1
  115. asp EM_PSIZE
  116. lfr EM_WSIZE
  117. ret EM_WSIZE
  118. end 0
  119. pro $topload1, 0
  120. #else
  121. pro $topload, 0
  122. #endif
  123. mes 11
  124. lal 0
  125. loi EM_PSIZE
  126. lae sv
  127. sti EM_PSIZE ; saved parameter
  128. lxl 0
  129. 2
  130. dup EM_PSIZE
  131. adp -3*EM_PSIZE
  132. lal 0
  133. loi EM_PSIZE ; compare target SP with current LB to see if we must
  134. loi EM_PSIZE
  135. cmp ; find another LB first
  136. zgt *1
  137. dch ; just follow dynamic chain to make sure we find
  138. ; a legal one
  139. bra *2
  140. 1
  141. str 0
  142. lae sv
  143. loi EM_PSIZE
  144. loi EM_PSIZE ; load indirect to
  145. str 1 ; restore SP
  146. asp -EM_PSIZE ; to stop int from complaining about non-existent memory
  147. lae sv
  148. loi EM_PSIZE ; source address
  149. lor 1
  150. adp EM_PSIZE ; destination address
  151. lae sv
  152. loi EM_PSIZE
  153. adp EM_PSIZE
  154. loi EM_WSIZE ; size of block
  155. bls EM_WSIZE
  156. asp EM_PSIZE+EM_WSIZE ; drop size + SP
  157. str 0 ; restore local base
  158. sim ; ignore mask
  159. lae 4
  160. sti EM_PSIZE
  161. ste 0 ; line and file
  162. loc 0
  163. ret EM_WSIZE
  164. end 0