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