2 * $XConsortium: stipmips.s,v 1.10 94/04/17 20:29:08 keith Exp $
4 Copyright (c) 1990 X Consortium
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 Except as contained in this notice, the name of the X Consortium shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the X Consortium.
27 * Author: Keith Packard, MIT X Consortium
31 * MIPS assembly code for optimized text rendering.
33 * Other stippling could be done in assembly, but the payoff is
34 * not nearly as large. Mostly because large areas are heavily
44 # define FourBits(dest,bits) and dest, bits, 0xf
51 # define FourBits(dest,bits) srl dest, bits, 28
54 /* reordering instructions would be fatal here */
59 * cfbStippleStack(addr, stipple, value, stride, Count, Shift)
60 * 4 5 6 7 16(sp) 20(sp)
62 * Apply successive 32-bit stipples starting at addr, addr+stride, ...
64 * Used for text rendering, but only when no data could be lost
65 * when the stipple is shifted left by Shift bits
84 #define CASE_SIZE 5 /* case blocks are 2^5 bytes each */
85 #define CASE_MASK 0x1e0 /* first case mask */
87 #define ForEachLine $200
89 #define NextLine1 $202
90 #define CaseBegin $203
91 #define ForEachBits $204
92 #define ForEachBits1 $205
96 #define cfbStippleStack cfbStippleStackTE
99 .globl cfbStippleStack
100 .ent cfbStippleStack 2
103 lw count, Count /* fetch stack params */
104 la sbase,CaseBegin /* load up switch table */
106 li lshift, 4 /* compute offset within */
107 subu lshift, lshift, shift /* stipple of remaining bits */
109 addu shift, shift, CASE_SIZE /* first shift for LSB */
111 addu shift, shift, 28-CASE_SIZE /* first shift for MSB */
113 /* do ... while (--count > 0); */
115 lw bits, 0(stipple) /* get stipple bits */
116 move atemp, addr /* set up for this line */
118 /* Terminal emulator fonts are expanded and have many 0 rows */
119 beqz bits, NextLine /* skip out early on 0 */
121 addu addr, addr, stride /* step for the loop */
122 BitsR stemp, bits, shift /* get first bits */
123 and stemp, stemp, CASE_MASK /* compute first branch */
124 addu stemp, stemp, sbase /* ... */
126 BitsL bits, bits, lshift /* set remaining bits */
131 FourBits(stemp, bits) /* compute jump for */
132 sll stemp, stemp, CASE_SIZE /* next four bits */
133 addu stemp, stemp, sbase /* ... */
135 BitsL bits, bits, 4 /* step for remaining bits */
137 bnez bits, ForEachBits1 /* 0 */
140 addu count, count, -1
141 bnez count, ForEachLine
142 addu stipple, stipple, 4
147 bnez bits, ForEachBits /* 1 */
148 sb value, BO(0)(atemp)
149 addu count, count, -1
150 bnez count, ForEachLine
151 addu stipple, stipple, 4
156 bnez bits, ForEachBits /* 2 */
157 sb value, BO(1)(atemp)
158 addu count, count, -1
159 bnez count, ForEachLine
160 addu stipple, stipple, 4
165 bnez bits, ForEachBits /* 3 */
166 sh value, HO(0)(atemp)
167 addu count, count, -1
168 bnez count, ForEachLine
169 addu stipple, stipple, 4
174 bnez bits, ForEachBits /* 4 */
175 sb value, BO(2)(atemp)
176 addu count, count, -1
177 bnez count, ForEachLine
178 addu stipple, stipple, 4
183 sb value, BO(0)(atemp) /* 5 */
184 bnez bits, ForEachBits
185 sb value, BO(2)(atemp)
186 addu count, count, -1
187 bnez count, ForEachLine
188 addu stipple, stipple, 4
192 sb value, BO(1)(atemp) /* 6 */
193 bnez bits, ForEachBits
194 sb value, BO(2)(atemp)
195 addu count, count, -1
196 bnez count, ForEachLine
197 addu stipple, stipple, 4
201 bnez bits, ForEachBits /* 7 */
202 swl value, BO(2)(atemp) /* untested on MSB */
203 addu count, count, -1
204 bnez count, ForEachLine
205 addu stipple, stipple, 4
210 bnez bits, ForEachBits /* 8 */
211 sb value, BO(3)(atemp)
212 addu count, count, -1
213 bnez count, ForEachLine
214 addu stipple, stipple, 4
219 sb value, BO(0)(atemp) /* 9 */
220 bnez bits, ForEachBits
221 sb value, BO(3)(atemp)
222 addu count, count, -1
223 bnez count, ForEachLine
224 addu stipple, stipple, 4
228 sb value, BO(1)(atemp) /* a */
229 bnez bits, ForEachBits
230 sb value, BO(3)(atemp)
231 addu count, count, -1
232 bnez count, ForEachLine
233 addu stipple, stipple, 4
237 sh value, HO(0)(atemp) /* b */
238 bnez bits, ForEachBits
239 sb value, BO(3)(atemp)
240 addu count, count, -1
241 bnez count, ForEachLine
242 addu stipple, stipple, 4
246 bnez bits, ForEachBits /* c */
247 sh value, HO(2)(atemp)
248 addu count, count, -1
249 bnez count, ForEachLine
250 addu stipple, stipple, 4
255 sb value, BO(0)(atemp) /* d */
256 bnez bits, ForEachBits
257 sh value, HO(2)(atemp)
258 addu count, count, -1
259 bnez count, ForEachLine
260 addu stipple, stipple, 4
264 bnez bits, ForEachBits /* e */
265 swr value, BO(1)(atemp) /* untested on MSB */
266 addu count, count, -1
267 bnez count, ForEachLine
268 addu stipple, stipple, 4
273 bnez bits, ForEachBits /* f */
274 sw value, WO(0)(atemp)
275 addu count, count, -1
276 bnez count, ForEachLine
277 addu stipple, stipple, 4