Initial revision
[ssr] / StraySrc / Libraries / Sapphire / sh / coRoutine
1 ;
2 ; coRoutine.sh
3 ;
4 ; Basic coroutine handling
5 ;
6 ; © 1994-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's Sapphire library.
12 ;
13 ; Sapphire is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
16 ; any later version.
17 ;
18 ; Sapphire is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
22 ;
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sapphire. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26
27 ;----- Overview -------------------------------------------------------------
28 ;
29 ; Functions provided:
30 ;
31 ; coRout_create
32 ; coRout_switch
33 ; coRout_destroy
34 ; coRout_end
35
36 [ :LNOT::DEF:coRoutine__dfn
37 GBLL coRoutine__dfn
38
39 ; --- coRout_create ---
40 ;
41 ; On entry: R0 == pointer to coroutine
42 ; R1 == R10 value to pass to coroutine
43 ; R2 == R12 value to pass to coroutine
44 ; R3 == size of stack to pass (0 for default)
45 ;
46 ; On exit: R0 == coroutine handle
47 ; May return an error
48 ;
49 ; Use: Creates a new coroutine. It may be given control using
50 ; coRout_switch. Its registers are on entry:
51 ;
52 ; R0 == its coroutine handle
53 ; R10 == value passed to coRout_create in R1
54 ; R12 == value passed to coRout_create in R2
55 ; R13 == pointer to the stack created for it
56
57 IMPORT coRout_create
58
59 ; --- coRout_switch ---
60 ;
61 ; On entry: R0 == coroutine to switch to, or 0 for main
62 ;
63 ; On exit: --
64 ;
65 ; Use: Switches context to another coroutine.
66
67 IMPORT coRout_switch
68
69 ; --- coRout_destroy ---
70 ;
71 ; On entry: R0 == coroutine handle to destroy
72 ;
73 ; On exit: --
74 ;
75 ; Use: Destroys a coroutine.
76
77 IMPORT coRout_destroy
78
79 ; --- coRout_end ---
80 ;
81 ; On entry: --
82 ;
83 ; On exit: Doesn't.
84 ;
85 ; Use: Terminates the current coroutine.
86
87 IMPORT coRout_end
88
89 ]
90
91 ;----- That's all, folks ----------------------------------------------------
92
93 END