2 * $XConsortium: stipsparc.s,v 1.9 94/04/17 20:29:09 rws 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 * SPARC 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
38 /* not that I expect to ever see an LSB SPARC, but ... */
45 # define FourBits(dest,bits) and bits, 0xf, dest
52 # define FourBits(dest,bits) srl bits, 28, dest
56 * cfbStippleStack(addr, stipple, value, stride, Count, Shift)
57 * 4 5 6 7 16(sp) 20(sp)
59 * Apply successive 32-bit stipples starting at addr, addr+stride, ...
61 * Used for text rendering, but only when no data could be lost
62 * when the stipple is shifted left by Shift bits
79 #define CASE_SIZE 5 /* case blocks are 2^5 bytes each */
80 #define CASE_MASK 0x1e0 /* first case mask */
82 #define ForEachLine LY1
85 #define ForEachBits LY4
88 #if defined(SVR4) || (defined(linux) && (defined(sparc) || defined(__sparc__)))
90 #define _cfbStippleStack cfbStippleStackTE
92 #define _cfbStippleStack cfbStippleStack
96 #define _cfbStippleStack _cfbStippleStackTE
101 .globl _cfbStippleStack
104 sethi %hi(CaseBegin),sbase /* load up switch table */
105 or sbase,%lo(CaseBegin),sbase
107 mov 4,lshift /* compute offset within */
108 sub lshift, shift, lshift /* stipple of remaining bits */
110 inc CASE_SIZE, shift /* first shift for LSB */
112 inc 28-CASE_SIZE, shift /* first shift for MSB */
114 /* do ... while (--count > 0); */
116 ld [stipple],bits /* get stipple bits */
117 mov addr,atemp /* set up for this line */
119 /* Terminal emulator fonts are expanded and have many 0 rows */
121 bz NextLine /* skip out early on 0 */
123 add addr, stride, addr /* step for the loop */
124 BitsR bits, shift, stemp /* get first bits */
125 and stemp, CASE_MASK, stemp /* compute first jump */
126 BitsL bits, lshift, bits /* set remaining bits */
127 jmp sbase+stemp /* ... */
133 FourBits(stemp, bits) /* compute jump for */
134 sll stemp, CASE_SIZE, stemp /* these four bits */
135 BitsL bits, 4, bits /* step for remaining bits */
136 jmp sbase+stemp /* jump */
139 bnz,a ForEachBits1 /* 0 */
149 bnz ForEachBits /* 1 */
150 stb value, [atemp+BO(0)]
158 bnz ForEachBits /* 2 */
159 stb value, [atemp+BO(1)]
167 bnz ForEachBits /* 3 */
168 sth value, [atemp+HO(0)]
176 bnz ForEachBits /* 4 */
177 stb value, [atemp+BO(2)]
185 stb value, [atemp+BO(0)] /* 5 */
187 stb value, [atemp+BO(2)]
194 stb value, [atemp+BO(1)] /* 6 */
196 stb value, [atemp+BO(2)]
203 sth value, [atemp+HO(0)] /* 7 */
205 stb value, [atemp+BO(2)]
212 bnz ForEachBits /* 8 */
213 stb value, [atemp+BO(3)]
221 stb value, [atemp+BO(0)] /* 9 */
223 stb value, [atemp+BO(3)]
230 stb value, [atemp+BO(1)] /* a */
232 stb value, [atemp+BO(3)]
239 sth value, [atemp+HO(0)] /* b */
241 stb value, [atemp+BO(3)]
248 bnz ForEachBits /* c */
249 sth value, [atemp+HO(2)]
257 stb value, [atemp+BO(0)] /* d */
259 sth value, [atemp+HO(2)]
266 stb value, [atemp+BO(1)] /* e */
268 sth value, [atemp+HO(2)]
275 bnz ForEachBits /* f */
276 st value, [atemp+WO(0)]