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