source: xtideuniversalbios/trunk/Assembly_Library/Src/String/Char.asm@ 616

Last change on this file since 616 was 592, checked in by Krister Nordvall, 6 years ago

Changes:

  • The problem with NASM in the previous revision (r591) has been fixed.
  • The colors used by the boot menu and hotkey bar can now be customized by selecting one of a number of pre-defined color themes. Suggestions for additional themes are more than welcome!
  • Large builds are now 10 KB. Small builds are still 8 KB with the exception of the Tiny build which is now 4 KB. In other words, builds are now as small as possible to make it easier to combine them with other BIOSes.
  • Added code to the library to improve drive error handling. XTIDECFG can now handle "Drive Not Ready" errors.
  • Fixed a couple of potential bugs in AtaID.asm (AtaID_GetMaxPioModeToAXandMinCycleTimeToCX); 1) ATA1.bPioMode was treated as a WORD variable. 2) ATA2.bPIOSupp was assumed to be non-zero which would result in PIO mode 3 being returned if the assumption was wrong.
  • Made the same changes in the equivalent function used by BIOSDRVS (DisplayPioModeInformationUsingAtaInfoFromDSBX in AtaInfo.asm).
  • Fixed a bug from r587 in PDC20x30.asm in PDC20x30_GetMaxPioModeToALandMinPioCycleTimeToBX.
  • Fixed a bug from r523 in XTIDECFG where Auto Configure would only set the IRQ on one IDE interface on AT-builds.
  • XTIDECFG will now restore the default settings for the "Serial port virtual device" when reselecting it in the list of device types. This makes it behave consistently for all device types.
  • The eAAM macro is now used regardless if USE_UNDOC_INTEL is defined or not because it is apparently supported on all processors including the NEC V20/V30 CPUs.
  • Renamed the EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS define to EXCLUDE_FROM_XUB.
  • Added a define to exclude unused library code from BIOSDRVS (EXCLUDE_FROM_BIOSDRVS). This makes it a lot smaller than in previous revisions.
  • All unnecessary CLD-instructions are now under a new define 'CLD_NEEDED' which is only enabled for the BIOS. It is disabled for XTIDECFG and BIOSDRVS but can be enabled if needed by adding this define to the respective makefile. This change was made because these unnecessary instructions are wasteful and should never be needed. In fact, they only serve to hide bugs (in other peoples code) which I strongly believe should be avoided. I recommend people making their own BIOSes from source to not use this define as it's extremely unlikely to be needed.
  • Updated the copyright info in SerDrive and changed an URL to point to the new site.
  • Updated the copyright info and version number in BIOSDRVS.
  • Updated the copyright info in XTIDECFG.
  • Optimizations in general.
File size: 7.4 KB
Line 
1; Project name : Assembly Library
2; Description : Functions for handling characters.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
24; This macro can only be used within this source file!!!
25; IS_BETWEEN_IMMEDIATES
26; Parameters:
27; %1: Value to check
28; %2: First accepted value in range
29; %3: Last accepted value in range
30; Returns:
31; CF: Set if character in range
32; (Jumps to Char_CharIsNotValid if before range)
33; Corrupts registers:
34; Nothing
35;--------------------------------------------------------------------
36%macro IS_BETWEEN_IMMEDIATES 3
37 cmp %1, %2
38 jb SHORT Char_CharIsNotValid
39 cmp %1, (%3)+1 ; Set CF if %1 is lesser
40%endmacro
41
42
43;--------------------------------------------------------------------
44; Char_IsLowerCaseLetterInAL
45; Parameters:
46; AL: Character to check
47; Returns:
48; CF: Set if character is lower case letter ('a'...'z')
49; Cleared if character is not lower case letter
50; Corrupts registers:
51; Nothing
52;--------------------------------------------------------------------
53%ifdef EXCLUDE_FROM_XUB
54 %ifndef MODULE_HOTKEYS
55 %define EXCLUDE
56 %endif
57%endif
58
59%ifndef EXCLUDE OR EXCLUDE_FROM_BIOSDRVS
60ALIGN STRING_JUMP_ALIGN
61Char_IsLowerCaseLetterInAL:
62 IS_BETWEEN_IMMEDIATES al, 'a', 'z'
63 ret
64%endif
65%undef EXCLUDE
66
67
68;--------------------------------------------------------------------
69; Char_IsUpperCaseLetterInAL
70; Parameters:
71; AL: Character to check
72; Returns:
73; CF: Set if character is upper case letter ('A'...'Z')
74; Cleared if character is not upper case letter
75; Corrupts registers:
76; Nothing
77;--------------------------------------------------------------------
78%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
79ALIGN STRING_JUMP_ALIGN
80Char_IsUpperCaseLetterInAL:
81 IS_BETWEEN_IMMEDIATES al, 'A', 'Z'
82 ret
83%endif
84
85
86;--------------------------------------------------------------------
87; Char_IsHexadecimalDigitInAL
88; Parameters:
89; AL: Character to check
90; Returns:
91; AL: Character converted to lower case
92; CF: Set if character is decimal digit ('0'...'F')
93; Cleared if character is not decimal digit
94; Corrupts registers:
95; Nothing
96;--------------------------------------------------------------------
97%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
98ALIGN STRING_JUMP_ALIGN
99Char_IsHexadecimalDigitInAL:
100 call Char_IsDecimalDigitInAL
101 jc SHORT Char_CharIsValid
102 call Char_ALtoLowerCaseLetter
103 IS_BETWEEN_IMMEDIATES al, 'a', 'f'
104 ret
105%endif
106
107
108;--------------------------------------------------------------------
109; Char_IsDecimalDigitInAL
110; Parameters:
111; AL: Character to check
112; Returns:
113; CF: Set if character is decimal digit ('0'...'9')
114; Cleared if character is not decimal digit
115; Corrupts registers:
116; Nothing
117;--------------------------------------------------------------------
118%ifndef MODULE_STRINGS_COMPRESSED
119ALIGN STRING_JUMP_ALIGN
120Char_IsDecimalDigitInAL:
121 IS_BETWEEN_IMMEDIATES al, '0', '9'
122 ret
123%endif
124
125
126;--------------------------------------------------------------------
127; Char_ConvertIntegerToALfromDigitInALwithBaseInBX
128; Parameters:
129; AL: Character to convert
130; BX: Numeric base (10 or 16)
131; Returns:
132; AL: Character converted to integer
133; CF: Set if character was valid
134; Cleared if character was invalid
135; Corrupts registers:
136; Nothing
137;--------------------------------------------------------------------
138%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
139ALIGN STRING_JUMP_ALIGN
140Char_ConvertIntegerToALfromDigitInALwithBaseInBX:
141 push dx
142 call Char_GetFilterFunctionToDXforNumericBaseInBX
143 call dx ; Converts to lower case
144 pop dx
145 jnc SHORT Char_CharIsNotValid
146
147 cmp al, '9' ; Decimal digit
148 jbe SHORT .ConvertToDecimalDigit
149 sub al, 'a'-'0'-10 ; Convert to hexadecimal integer
150ALIGN STRING_JUMP_ALIGN
151.ConvertToDecimalDigit:
152 sub al, '0' ; Convert to decimal integer
153 ; Fall to Char_CharIsValid
154%endif
155
156
157;--------------------------------------------------------------------
158; Char_CharIsValid
159; Char_CharIsNotValid
160; Parameters:
161; Nothing
162; Returns:
163; CF: Set for Char_CharIsValid
164; Cleared for Char_CharIsNotValid
165; Corrupts registers:
166; Nothing
167;--------------------------------------------------------------------
168%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
169ALIGN STRING_JUMP_ALIGN
170Char_CharIsValid:
171 stc
172 ret
173%endif
174
175
176%ifdef EXCLUDE_FROM_XUB
177 %ifndef MODULE_HOTKEYS
178 %define EXCLUDE
179 %endif
180 %ifndef MODULE_STRINGS_COMPRESSED
181 %undef EXCLUDE
182 %endif
183%endif
184
185%ifndef EXCLUDE
186ALIGN STRING_JUMP_ALIGN
187Char_CharIsNotValid:
188 clc
189 ret
190%endif
191%undef EXCLUDE
192
193
194;--------------------------------------------------------------------
195; Char_ALtoLowerCaseLetter
196; Parameters:
197; AL: Character to convert
198; Returns:
199; AL: Character with possible conversion
200; Corrupts registers:
201; Nothing
202;--------------------------------------------------------------------
203%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
204ALIGN STRING_JUMP_ALIGN
205Char_ALtoLowerCaseLetter:
206 call Char_IsUpperCaseLetterInAL ; Is upper case character?
207 jmp SHORT Char_ALtoUpperCaseLetter.CheckCF
208%endif
209
210
211;--------------------------------------------------------------------
212; Char_ALtoUpperCaseLetter
213; Parameters:
214; AL: Character to convert
215; Returns:
216; AL: Character with possible conversion
217; Corrupts registers:
218; Nothing
219;--------------------------------------------------------------------
220%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
221ALIGN STRING_JUMP_ALIGN
222Char_ALtoUpperCaseLetter:
223 call Char_IsLowerCaseLetterInAL ; Is lower case character?
224.CheckCF:
225 jnc SHORT Char_ChangeCaseInAL.Return
226 ; Fall to Char_ChangeCaseInAL
227%endif
228
229
230;--------------------------------------------------------------------
231; Char_ChangeCaseInAL
232; Parameters:
233; AL: Character to convert (must be A-Z or a-z)
234; Returns:
235; AL: Character converted
236; Corrupts registers:
237; Nothing
238;--------------------------------------------------------------------
239%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
240Char_ChangeCaseInAL:
241 xor al, 32
242.Return:
243 ret
244%endif
245
246
247;--------------------------------------------------------------------
248; Char_GetFilterFunctionToDXforNumericBaseInBX
249; Parameters
250; BX: Numeric base (10 or 16)
251; Returns:
252; CS:DX: Ptr to character filter function
253; Corrupts registers:
254; Nothing
255;--------------------------------------------------------------------
256%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
257ALIGN STRING_JUMP_ALIGN
258Char_GetFilterFunctionToDXforNumericBaseInBX:
259 mov dx, Char_IsDecimalDigitInAL
260 cmp bl, 10
261 je SHORT .Return
262 mov dx, Char_IsHexadecimalDigitInAL
263.Return:
264 ret
265%endif
Note: See TracBrowser for help on using the repository browser.