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

Last change on this file since 500 was 491, checked in by krille_n_@…, 12 years ago

Changes:

  • Added a new define (USE_UNDOC_INTEL) that enables optimizations possible by using undocumented instructions available on all Intel processors and truly compatible clones. AFAIK the only exceptions are the NEC V-series and the Sony CXQ70108 processors so this option should be safe for use on the AT builds.
  • Building BIOSDRVS or the BIOS without MODULE_STRINGS_COMPRESSED would fail due to the recent code exclusions so I changed them a bit. Also fixed the mistaken change to Main.asm
  • Changed the Tandy specific info in Configuration_FullMode.txt so it matches the info in the Wiki.
  • Optimizations and fixes in general.
File size: 7.3 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
[376]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 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.
[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;--------------------------------------------------------------------
[491]53%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
54 %ifndef MODULE_HOTKEYS
55 %define EXCLUDE
56 %endif
57%endif
58
59%ifndef EXCLUDE
[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;--------------------------------------------------------------------
[162]78%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[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;--------------------------------------------------------------------
[162]97%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[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;--------------------------------------------------------------------
[162]138%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[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;--------------------------------------------------------------------
[162]168%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[369]169ALIGN STRING_JUMP_ALIGN
[41]170Char_CharIsValid:
171 stc
172 ret
[162]173%endif
[41]174
[491]175
176%ifdef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
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;--------------------------------------------------------------------
[162]203%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[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;--------------------------------------------------------------------
[491]220%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[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;--------------------------------------------------------------------
[491]239%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[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;--------------------------------------------------------------------
[162]256%ifndef EXCLUDE_FROM_XTIDE_UNIVERSAL_BIOS
[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.