chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Sapphire / sh / libOpts
1 ;
2 ; libOpts.sh
3 ;
4 ; Allow options for library units to be declared
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 ;  libOpts_register
32 ;  libOpts_find
33 ;
34 ; Macros provided:
35 ;
36 ;  LIBOPT
37 ;  LOEND
38
39                 [       :LNOT::DEF:libOpts__dfn
40                 GBLL    libOpts__dfn
41
42 ;+              LIB     sapphire:^.bsh.libOpts
43
44 ; --- libOpts_register ---
45 ;
46 ; On entry:     R0 == address of an options block
47 ;
48 ; On exit:      --
49 ;
50 ; Use:          Adds the block given to the library options.
51
52                 IMPORT  libOpts_register
53
54 ; --- libOpts_find ---
55 ;
56 ; On entry:     R0 == magic marker word
57 ;
58 ; On exit:      CS if found, and
59 ;                 R0 == address of options block
60 ;               else CC, and
61 ;                 R0 corrupted
62 ;
63 ; Use:          Tries to find an option with the given marker, which will
64 ;               normally be a four-character text string.  The first match
65 ;               found will be returned.  The options blocks are searched in
66 ;               reverse order of registration (i.e. blocks registered later
67 ;               will override blocks registered reviously).
68
69                 IMPORT  libOpts_find
70
71 ;----- Macros ---------------------------------------------------------------
72
73                 GBLA    lo__c
74 lo__c           SETA    0
75                 GBLL    lo__p
76 lo__p           SETL    {FALSE}
77
78 ; --- Macro: LIBOPT ---
79 ;
80 ; Arguments:    name == name of this options subblock (4 characters)
81 ;
82 ; Use:          Sets up an options subblock with the given name.
83
84                 MACRO
85 $label          LIBOPT  $name
86                 ALIGN
87
88                 [       lo__p
89 lo__sz$lo__c    EQU     {PC}-lo__a$lo__c
90                 ]
91 lo__c           SETA    lo__c+1
92
93 $label
94                 DCB     "$name"
95                 DCD     lo__sz$lo__c
96 lo__a$lo__c
97 lo__p           SETL    {TRUE}
98
99                 MEND
100
101 ; --- Macro: LOEND ---
102 ;
103 ; Arguments:    --
104 ;
105 ; Use:          Terminates a library options block.
106
107                 MACRO
108                 LOEND
109                 ALIGN
110
111                 [       lo__p
112 lo__sz$lo__c    EQU     {PC}-lo__a$lo__c
113                 ]
114 lo__c           SETA    lo__c+1
115 lo__p           SETL    {FALSE}
116
117                 DCD     -1
118
119                 MEND
120
121                 ]
122
123 ;----- That's all, folks ----------------------------------------------------
124
125                 END