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

Last change on this file since 614 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
RevLine 
[41]1; Project name : Assembly Library
2; Description : Functions for handling characters.
3
[376]4;
[491]5; XTIDE Universal BIOS and Associated Tools
[526]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]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.
[491]12;
[376]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
[491]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[491]18;
[376]19
[41]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:
[491]31; CF: Set if character in range
[162]32; (Jumps to Char_CharIsNotValid if before range)
[41]33; Corrupts registers:
34; Nothing
35;--------------------------------------------------------------------
36%macro IS_BETWEEN_IMMEDIATES 3
37 cmp %1, %2
[162]38 jb SHORT Char_CharIsNotValid
[41]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;--------------------------------------------------------------------
[592]53%ifdef EXCLUDE_FROM_XUB
[491]54 %ifndef MODULE_HOTKEYS
55 %define EXCLUDE
56 %endif
57%endif
58
[592]59%ifndef EXCLUDE OR EXCLUDE_FROM_BIOSDRVS
[369]60ALIGN STRING_JUMP_ALIGN
[41]61Char_IsLowerCaseLetterInAL:
62 IS_BETWEEN_IMMEDIATES al, 'a', 'z'
63 ret
[491]64%endif
65%undef EXCLUDE
[41]66
[491]67
[41]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;--------------------------------------------------------------------
[592]78%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
[369]79ALIGN STRING_JUMP_ALIGN
[41]80Char_IsUpperCaseLetterInAL:
81 IS_BETWEEN_IMMEDIATES al, 'A', 'Z'
82 ret
[162]83%endif
[41]84
[491]85
[41]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;--------------------------------------------------------------------
[592]97%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
[369]98ALIGN STRING_JUMP_ALIGN
[41]99Char_IsHexadecimalDigitInAL:
100 call Char_IsDecimalDigitInAL
101 jc SHORT Char_CharIsValid
102 call Char_ALtoLowerCaseLetter
103 IS_BETWEEN_IMMEDIATES al, 'a', 'f'
104 ret
[162]105%endif
[41]106
[491]107
[41]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;--------------------------------------------------------------------
[201]118%ifndef MODULE_STRINGS_COMPRESSED
[369]119ALIGN STRING_JUMP_ALIGN
[41]120Char_IsDecimalDigitInAL:
121 IS_BETWEEN_IMMEDIATES al, '0', '9'
122 ret
[194]123%endif
[41]124
[491]125
[41]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;--------------------------------------------------------------------
[592]138%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
[369]139ALIGN STRING_JUMP_ALIGN
[41]140Char_ConvertIntegerToALfromDigitInALwithBaseInBX:
141 push dx
142 call Char_GetFilterFunctionToDXforNumericBaseInBX
143 call dx ; Converts to lower case
144 pop dx
[162]145 jnc SHORT Char_CharIsNotValid
[41]146
147 cmp al, '9' ; Decimal digit
148 jbe SHORT .ConvertToDecimalDigit
[145]149 sub al, 'a'-'0'-10 ; Convert to hexadecimal integer
[369]150ALIGN STRING_JUMP_ALIGN
[41]151.ConvertToDecimalDigit:
152 sub al, '0' ; Convert to decimal integer
[162]153 ; Fall to Char_CharIsValid
154%endif
[41]155
[491]156
[41]157;--------------------------------------------------------------------
[162]158; Char_CharIsValid
159; Char_CharIsNotValid
[41]160; Parameters:
161; Nothing
162; Returns:
[162]163; CF: Set for Char_CharIsValid
164; Cleared for Char_CharIsNotValid
[41]165; Corrupts registers:
166; Nothing
167;--------------------------------------------------------------------
[592]168%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
[369]169ALIGN STRING_JUMP_ALIGN
[41]170Char_CharIsValid:
171 stc
172 ret
[162]173%endif
[41]174
[491]175
[592]176%ifdef EXCLUDE_FROM_XUB
[491]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
[369]186ALIGN STRING_JUMP_ALIGN
[162]187Char_CharIsNotValid:
[41]188 clc
189 ret
[491]190%endif
191%undef EXCLUDE
[41]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;--------------------------------------------------------------------
[592]203%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
[369]204ALIGN STRING_JUMP_ALIGN
[41]205Char_ALtoLowerCaseLetter:
206 call Char_IsUpperCaseLetterInAL ; Is upper case character?
[181]207 jmp SHORT Char_ALtoUpperCaseLetter.CheckCF
[162]208%endif
[41]209
[491]210
[41]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;--------------------------------------------------------------------
[592]220%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
[369]221ALIGN STRING_JUMP_ALIGN
[41]222Char_ALtoUpperCaseLetter:
223 call Char_IsLowerCaseLetterInAL ; Is lower case character?
[181]224.CheckCF:
225 jnc SHORT Char_ChangeCaseInAL.Return
226 ; Fall to Char_ChangeCaseInAL
[489]227%endif
[181]228
[491]229
[181]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;--------------------------------------------------------------------
[592]239%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
[181]240Char_ChangeCaseInAL:
241 xor al, 32
[41]242.Return:
243 ret
[491]244%endif
[41]245
[491]246
[41]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;--------------------------------------------------------------------
[592]256%ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_BIOSDRVS
[369]257ALIGN STRING_JUMP_ALIGN
[41]258Char_GetFilterFunctionToDXforNumericBaseInBX:
259 mov dx, Char_IsDecimalDigitInAL
260 cmp bl, 10
261 je SHORT .Return
[162]262 mov dx, Char_IsHexadecimalDigitInAL
[41]263.Return:
264 ret
[162]265%endif
Note: See TracBrowser for help on using the repository browser.