source: xtideuniversalbios/trunk/Assembly_Library/Src/String/String.asm@ 609

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

Changes:

  • Update of the copyright notices to include the year 2013.
File size: 3.5 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; String_ConvertDSSItoLowerCase
25; Parameters:
26; DS:SI: Ptr to string to convert
27; Returns:
28; CX: Number of characters processed
29; SI: Updated
30; Corrupts registers:
31; Nothing
32;--------------------------------------------------------------------
33ALIGN STRING_JUMP_ALIGN
34String_ConvertDSSItoLowerCase:
35 push dx
36 push ax
37
38 mov dx, StringProcess_ConvertToLowerCase
39 call StringProcess_DSSIwithFunctionInDX
40
41 pop ax
42 pop dx
43 ret
44
45
46;--------------------------------------------------------------------
47; String_ConvertWordToAXfromStringInDSSIwithBaseInBX
48; Parameters:
49; BX: Numeric base (10 or 16)
50; DS:SI: Ptr to string to convert
51; Returns:
52; AX: Word converted from string
53; CX: Number of characters processed
54; SI: Updated
55; CF: Cleared if successful
56; Set if error during conversion
57; Corrupts registers:
58; Nothing
59;--------------------------------------------------------------------
60ALIGN STRING_JUMP_ALIGN
61String_ConvertWordToAXfromStringInDSSIwithBaseInBX:
62 push di
63 push dx
64
65 xor di, di
66 mov dx, StringProcess_ConvertToWordInDIWithBaseInBX
67 call StringProcess_DSSIwithFunctionInDX
68 xchg ax, di
69
70 pop dx
71 pop di
72 ret
73
74
75;--------------------------------------------------------------------
76; String_CopyDSSItoESDIandGetLengthToCX
77; Parameters:
78; DS:SI: Ptr to source NULL terminated string
79; ES:DI: Ptr to destination buffer
80; Returns:
81; CX: Number of characters copied
82; SI,DI: Updated by CX characters
83; Corrupts registers:
84; Nothing
85;--------------------------------------------------------------------
86ALIGN STRING_JUMP_ALIGN
87String_CopyDSSItoESDIandGetLengthToCX:
88 push ax
89
90 xor cx, cx
91ALIGN STRING_JUMP_ALIGN
92.CopyNextCharacter:
93 lodsb ; Load from DS:SI to AL
94 test al, al ; NULL to end string?
95 jz SHORT .EndOfString
96 stosb ; Store from AL to ES:DI
97 inc cx ; Increment number of characters written
98 jmp SHORT .CopyNextCharacter
99
100ALIGN STRING_JUMP_ALIGN
101.EndOfString:
102 pop ax
103 ret
104
105
106;--------------------------------------------------------------------
107; String_GetLengthFromDSSItoCX
108; Parameters:
109; DS:SI: Ptr to NULL terminated string
110; Returns:
111; CX: String length in characters
112; Corrupts registers:
113; Nothing
114;--------------------------------------------------------------------
115ALIGN STRING_JUMP_ALIGN
116String_GetLengthFromDSSItoCX:
117 push ax
118 push si
119
120 call Registers_ExchangeDSSIwithESDI
121 xor ax, ax ; Find NULL
122 mov cx, -1 ; Full segment if necessary
123 repne scasb
124 mov cx, di
125 call Registers_ExchangeDSSIwithESDI
126
127 pop si
128 stc
129 sbb cx, si ; Subtract NULL
130 pop ax
131 ret
Note: See TracBrowser for help on using the repository browser.