Initial revision
[ssr] / StraySrc / Libraries / Sapphire / csapph / s / crout
1 ;
2 ; crout.s
3 ;
4 ; Some interfaces to standard Sapphire routines
5 ;
6 ; © 1995 Straylight
7 ;
8
9 ;----- Standard header ------------------------------------------------------
10
11 GET libs:header
12 ; GET libs:swis
13
14 GET libs:stream
15
16 ;----- External dependencies ------------------------------------------------
17
18 GET sapphire:alloc
19 GET sapphire:flex
20 GET sapphire:msgs
21 GET sapphire:sapphire
22 GET sapphire:string
23
24 ;----- Macros ---------------------------------------------------------------
25
26 MACRO
27 $label PREAMBLE
28 $label STMFD sp!,{R11,lr}
29 MOV R11,sl
30 MEND
31
32 MACRO
33 $label POSTAMBLE
34 $label LDMFD sp!,{R11,pc}^
35 MEND
36
37 MACRO
38 $label VENEER
39 EXPORT __sapph_$label
40 __sapph_$label PREAMBLE
41 BL $label
42 POSTAMBLE
43 MEND
44
45 MACRO
46 $label FLEXVNR
47 EXPORT __sapph_$label
48 __sapph_$label PREAMBLE
49 BL $label
50 MOVCS a1,#0
51 LDRCC a1,[a1,#0]
52 POSTAMBLE
53 MEND
54
55 ;----- Main code ------------------------------------------------------------
56
57 AREA |Sapphire$$Code|,CODE,READONLY
58
59 ; --- __sapph_scratchpad ---
60
61 EXPORT |__sapph_scratchpad|
62 |__sapph_scratchpad|
63 MOV a1,sl
64 MOVS pc,lr
65
66 ; --- strsubst ---
67
68 EXPORT strsubst
69 strsubst MOV ip,sp
70 STMFD sp!,{R4-R11,lr}
71 MOV R11,sl
72 LDMIA ip,{R4-R10}
73 BL str_subst
74 LDMFD sp!,{R4-R11,pc}^
75
76 ; --- strcmp ---
77 ; --- stricmp ---
78
79 EXPORT strcmp
80 EXPORT stricmp
81
82 strcmp MOV ip,lr
83 BL str_cmp
84 B %10
85
86 stricmp MOV ip,lr
87 BL str_icmp
88
89 10 MOVLT a1,#-1
90 MOVEQ a1,#0
91 MOVGT a1,#1
92 MOVS pc,ip
93
94 LTORG
95
96 ; --- strbuffer ---
97
98 EXPORT strbuffer
99 strbuffer PREAMBLE
100 BL str_buffer
101 MOV a1,R1
102 POSTAMBLE
103
104 ; --- strerror ---
105
106 EXPORT strerror
107 strerror MOV ip,sp
108 STMFD sp!,{R4-R11,lr}
109 MOV R11,sl
110 LDMIA ip,{R4-R10}
111 MOV ip,a2
112 BL str_buffer
113 STR a1,[a2],#4
114 MOV a1,ip
115 BL str_subst
116 SUB a1,a1,#4
117 LDMFD sp!,{R4-R11,pc}^
118
119 ; --- msgs_lookup ---
120
121 msgs_lookup VENEER
122
123 ; --- msgs_error ---
124
125 EXPORT |__sapph_msgs_error|
126 |__sapph_msgs_error|
127 MOV ip,sp
128 STMFD sp!,{R4-R11,lr}
129 MOV R11,sl
130 LDMIA ip,{R4-R10}
131 MOV ip,a2
132 BL str_buffer
133 STR a1,[a2],#4
134 MOV a1,ip
135 BL msgs_lookup
136 BL str_subst
137 SUB a1,a1,#4
138 LDMFD sp!,{R4-R11,pc}^
139
140 ; --- malloc ---
141
142 EXPORT malloc
143 malloc CMP a1,#0
144 MOVEQS pc,lr
145 PREAMBLE
146 BL alloc
147 MOVCS a1,#0
148 POSTAMBLE
149
150 ; --- free ---
151
152 EXPORT |__sapph_free|
153 |__sapph_free| CMP a1,#0
154 MOVEQS pc,lr
155 PREAMBLE
156 BL free
157 POSTAMBLE
158
159 ; --- alloc_error ---
160
161 alloc_error VENEER
162
163 ; --- flex ---
164
165 flex_alloc FLEXVNR
166 flex_free VENEER
167 flex_size VENEER
168 flex_extend FLEXVNR
169 flex_midExtend FLEXVNR
170
171 EXPORT |__sapph_flex_save|
172 |__sapph_flex_save|
173 PREAMBLE
174 FSAVE R0
175 POSTAMBLE
176
177 EXPORT |__sapph_flex_load|
178 |__sapph_flex_load|
179 PREAMBLE
180 FLOAD R0
181 POSTAMBLE
182
183 ;----- That's all, folks ----------------------------------------------------
184
185 END