3 Appendix B: Translation of a \fBPAR\fP construct to EM code using the library
4 routines to simulate parallelism
6 Translation of the parallel construct:
18 lal -20 ; Assume 20 bytes of local variables at this moment
19 cal $parbegin ; Set up a process group
20 asp 4 ; Assume pointersize = 4
21 cal $parfork ; Split stack in two from local -20
22 lfr 4 ; Assume wordsize = 4
23 zne *23 ; One end jumps to second process, other continues here
27 bra *24 ; Jump to the outer parend
29 cal $parfork ; Fork off `par i = ...' process
31 zne *25 ; One end jumps to end of outer par
32 lal -20 ; Place break just above i
33 cal $parbegin ; Set up another process group for the P(i)
36 lol n ; Assume n can be addressed this simply
37 stl -28 ; A nameless counter
38 bra *26 ; Branch to counter test
40 cal $parfork ; Fork off one P(i)
42 zne *28 ; One jumps away to increment i, the other calls P(i)
50 del -28 ; counter:=counter-1
53 zgt *27 ; while counter>0 repeat loop
55 cal $parend ; Wait for the P(i) to finish, then delete group
56 bra *24 ; Jump to the higher up meeting place with P0
57 25 ; Note that the bra will be optimized away
59 cal $parend ; Wait for both processes to end, then delete group