4 ; A ctype implementation done the proper way
9 ;----- Standard header ------------------------------------------------------
16 ;----- External dependencies ------------------------------------------------
20 ;----- Main code ------------------------------------------------------------
22 AREA |Sapphire$$Code|,CODE,READONLY
24 ; --- Character table format ---
26 ; The table consists of halfword entries, which have the following format:
44 ; Use: Sets up the character translation table.
49 STMFD R13!,{R0-R5,R14} ;Save some registers
50 ADR R2,ctype__table ;Point to the main table
51 ADR R3,ctype__terrTrans ;Point to territory decode
53 10 LDRB R1,[R3],#1 ;Load property number
54 CMP R1,#255 ;Is this the end?
55 BEQ %f10 ;Yes -- return then
56 MOV R0,#-1 ;Get the current territory
57 SWI XTerritory_CharacterPropertyTable
58 BVS %90ctype_init ;If not there, quit now
59 LDRB R1,[R3],#1 ;Load the bit number
61 MOV R4,#0 ;Initialise a counter
62 00 TST R4,#&1F000000 ;Run out of bits?
63 LDREQ R5,[R0],#4 ;Yes -- load some more then
64 MOVS R5,R5,LSR #1 ;Put a bit in carry
65 LDRB R14,[R2,R4,LSR #24] ;Load the byte
66 BICCC R14,R14,R1 ;Maybe clear the bit
67 ORRCS R14,R14,R1 ;Maybe set it
68 STRB R14,[R2,R4,LSR #24] ;Store the byte back
69 ADDS R4,R4,#&01000000 ;Increment the counter
70 BCC %b00 ;And loop until done
71 B %b10 ;Skip back for next bit
73 10 MOV R0,#-1 ;Use current territory
74 SWI XTerritory_UpperCaseTable ;Find upper case table
75 MOVVC R1,R0 ;Remember this value
76 MOVVC R0,#-1 ;Current territory again
77 SWIVC XTerritory_LowerCaseTable ;And get the lower table
78 BVS %90ctype_init ;If not there, quit now
80 MOV R3,#0 ;Get a counter going
81 00 LDRB R14,[R2],#1 ;Load the flags byte
82 MOVS R14,R14,LSL #28 ;Put letter bits away
83 LDRCSB R14,[R0,R3,LSR #24] ;If uppercase, get lower
84 LDRMIB R14,[R1,R3,LSR #24] ;Otherwise get upper
85 STRB R14,[R2,#255] ;Store in the table nicely
86 ADDS R3,R3,#&01000000 ;Move pointers on
87 BCC %b00 ;And keep going until done
89 90ctype_init LDMFD R13!,{R0-R5,PC}^ ;Return when finished
100 ctype__terrTrans DCB 0,C
110 ctype__table DCB C, C, C, C, C, C, C, C
111 DCB C+S, C+S, C+S, C+S, C+S, C+S, C, C
112 DCB C, C, C, C, C, C, C, C
113 DCB C, C, C, C, C, C, C, C
114 DCB B, P, P, P, P, P, P, P
115 DCB P, P, P, P, P, P, P, P
116 DCB D, D, D, D, D, D, D, D
117 DCB D, D, P, P, P, P, P, P
118 DCB P, U+X, U+X, U+X, U+X, U+X, U+X, U
119 DCB U, U, U, U, U, U, U, U
120 DCB U, U, U, U, U, U, U, U
121 DCB U, U, U, P, P, P, P, P
122 DCB P, L+X, L+X, L+X, L+X, L+X, L+X, L
123 DCB L, L, L, L, L, L, L, L
124 DCB L, L, L, L, L, L, L, L
125 DCB L, L, L, P, P, P, P, C
127 DCB P, P, P, P, P, U, L, P
128 DCB P, P, P, P, P, P, P, P
129 DCB P, P, P, P, P, P, P, P
130 DCB P, P, U, L, P, P, P, P
131 DCB P, P, P, P, P, P, P, P
132 DCB P, P, P, P, P, P, P, P
133 DCB P, P, P, P, P, P, P, P
134 DCB P, P, P, P, P, P, P, P
135 DCB U, U, U, U, U, U, U, U
136 DCB U, U, U, U, U, U, U, U
137 DCB U, U, U, U, U, U, U, P
138 DCB U, U, U, U, U, U, U, L
139 DCB L, L, L, L, L, L, L, L
140 DCB L, L, L, L, L, L, L, L
141 DCB L, L, L, L, L, L, L, P
142 DCB L, L, L, L, L, L, L, L
144 DCB 0, 0, 0, 0, 0, 0, 0, 0
145 DCB 0, 0, 0, 0, 0, 0, 0, 0
146 DCB 0, 0, 0, 0, 0, 0, 0, 0
147 DCB 0, 0, 0, 0, 0, 0, 0, 0
148 DCB 0, 0, 0, 0, 0, 0, 0, 0
149 DCB 0, 0, 0, 0, 0, 0, 0, 0
150 DCB 0, 0, 0, 0, 0, 0, 0, 0
151 DCB 0, 0, 0, 0, 0, 0, 0, 0
152 DCB 0, 'a', 'b', 'c', 'd', 'e', 'f', 'g'
153 DCB 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'
154 DCB 'p', 'q', 'r', 's', 't', 'u', 'v', 'w'
155 DCB 'x', 'y', 'z', 0, 0, 0, 0, 0
156 DCB 0, 'A', 'B', 'C', 'D', 'E', 'F', 'G'
157 DCB 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O'
158 DCB 'P', 'Q', 'R', 'S', 'T', 'I', 'V', 'W'
159 DCB 'X', 'Y', 'Z', 0, 0, 0, 0, 0
161 DCB 0, 0, 0, 0, 0, '
\86', '
\85', 0
162 DCB 0, 0, 0, 0, 0, 0, 0, 0
163 DCB 0, 0, 0, 0, 0, 0, 0, 0
164 DCB 0, 0, '
\9b', '
\9a', 0, 0, 0, 0
165 DCB 0, 0, 0, 0, 0, 0, 0, 0
166 DCB 0, 0, 0, 0, 0, 0, 0, 0
167 DCB 0, 0, 0, 0, 0, 0, 0, 0
168 DCB 0, 0, 0, 0, 0, 0, 0, 0
169 DCB 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç'
170 DCB 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï'
171 DCB 'ð', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 0
172 DCB 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'þ', 'ß'
173 DCB 'À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç'
174 DCB 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï'
175 DCB 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 0
176 DCB 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'Þ', 'Y'
180 ; --- ctype_findTable ---
184 ; On exit: R0 == pointer to table
186 ; Use: Finds the character table.
188 EXPORT ctype_findTable
196 ; --- Other ctype routines ---
199 toupper ADRL R1,ctype__table
206 tolower ADRL R1,ctype__table
212 ;----- That's all, folks ----------------------------------------------------