par_misc.e 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. ; This has been taken from the ACK Modula-2 runtime system and adapted.
  12. ;
  13. mes 2,EM_WSIZE,EM_PSIZE
  14. ;
  15. ; ___topsave: save the stack by sending it to the debugger
  16. ;
  17. exp $___topsave
  18. pro $___topsave, 0
  19. #ifdef __sparc
  20. inp $___topsave1
  21. inp $___topsave2
  22. cal $___topsave1
  23. lfr EM_WSIZE
  24. ret EM_WSIZE
  25. end 0
  26. pro $___topsave1,0
  27. cal $___topsave2
  28. lfr EM_WSIZE
  29. ret EM_WSIZE
  30. end 0
  31. pro $___topsave2,0
  32. #endif
  33. mes 11
  34. loe 0
  35. lae 4 ; load line number and file name
  36. loi EM_PSIZE
  37. lim ; load ignore mask
  38. lor 0 ; load LB
  39. ; now find the last argument base: first find the local base that has
  40. ; dynamic link 0.
  41. lor 0
  42. 1
  43. dup EM_PSIZE
  44. dch
  45. zer EM_PSIZE
  46. cmp
  47. zeq *2
  48. dch
  49. bra *1
  50. 2
  51. lpb ; last argument base
  52. ; Now the stuff between the current stack pointer and this argument base
  53. ; is saved by sending it to the debugger.
  54. lor 1
  55. sbs EM_WSIZE
  56. loc EM_WSIZE
  57. adu EM_WSIZE ; gives size
  58. lor 1 ; SP (the SP BEFORE pushing)
  59. lor 1 ; SP (address of stack top to save)
  60. cal $___sendtop ; ___sendtop(char *address, char *SP, unsigned size)
  61. asp 4*EM_PSIZE+3*EM_WSIZE ; remove the lot from the stack
  62. loc 1
  63. ret EM_WSIZE ; return 1
  64. end 0
  65. exp $___topload
  66. pro $___topload, 0
  67. #ifdef __sparc
  68. inp $___topload1
  69. inp $___topload2
  70. cal $___topload1
  71. lfr EM_WSIZE
  72. ret EM_WSIZE
  73. end 0
  74. pro $___topload1,0
  75. lxl 0
  76. dch
  77. lpb
  78. loi EM_PSIZE
  79. cal $___topload2
  80. asp EM_PSIZE
  81. lfr EM_WSIZE
  82. ret EM_WSIZE
  83. end 0
  84. pro $___topload2,0
  85. #endif
  86. mes 11
  87. lal 0
  88. loi EM_PSIZE
  89. lxl 0
  90. 2
  91. dup EM_PSIZE
  92. adp -3*EM_PSIZE
  93. lal 0
  94. loi EM_PSIZE ; compare target SP with current LB to see if we must
  95. cmp ; find another LB first
  96. zgt *1
  97. dch ; just follow dynamic chain to make sure we find
  98. ; a legal one
  99. bra *2
  100. 1
  101. str 0
  102. str 1 ; restore SP
  103. lor 1
  104. adp -EM_PSIZE
  105. #ifdef __sparc
  106. inp $restore
  107. cal $restore
  108. #else
  109. cal $___restoretop ; ___restoretop(char *SP)
  110. #endif
  111. asp EM_PSIZE+EM_WSIZE
  112. str 0 ; restore local base
  113. sim ; ignore mask
  114. lae 4
  115. sti EM_PSIZE
  116. ste 0 ; line and file
  117. loc 0
  118. ret EM_WSIZE ; return 0
  119. end 0
  120. #ifdef __sparc
  121. pro $restore
  122. mes 11
  123. lal 0
  124. loi EM_PSIZE
  125. cal $___restoretop
  126. asp EM_PSIZE
  127. ret 0
  128. end 0
  129. #endif