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

Last change on this file since 54 was 54, checked in by Tomi Tilli, 14 years ago

Changes to Assembly Library:
Drive selection moved to own dialog from File Dialog.
File Dialog now displays loading text for better usability in slow systems.
Moved some functions from Memory.asm to new Registers.asm.

File size: 2.9 KB
Line 
1; File name : String.asm
2; Project name : Assembly Library
3; Created date : 12.7.2010
4; Last update : 24.10.2010
5; Author : Tomi Tilli
6; Description : Functions for handling characters.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; String_ConvertDSSItoLowerCase
13; Parameters:
14; DS:SI: Ptr to string to convert
15; Returns:
16; CX: Number of characters processed
17; SI: Updated
18; Corrupts registers:
19; Nothing
20;--------------------------------------------------------------------
21ALIGN JUMP_ALIGN
22String_ConvertDSSItoLowerCase:
23 push dx
24 push ax
25
26 mov dx, StringProcess_ConvertToLowerCase
27 call StringProcess_DSSIwithFunctionInDX
28
29 pop ax
30 pop dx
31 ret
32
33
34;--------------------------------------------------------------------
35; String_ConvertWordToAXfromStringInDSSIwithBaseInBX
36; Parameters:
37; BX: Numeric base (10 or 16)
38; DS:SI: Ptr to string to convert
39; Returns:
40; AX: Word converted from string
41; CX: Number of characters processed
42; SI: Updated
43; CF: Cleared if successfull
44; Set if error during conversion
45; Corrupts registers:
46; Nothing
47;--------------------------------------------------------------------
48ALIGN JUMP_ALIGN
49String_ConvertWordToAXfromStringInDSSIwithBaseInBX:
50 push di
51 push dx
52
53 xor di, di
54 mov dx, StringProcess_ConvertToWordInDIWithBaseInBX
55 call StringProcess_DSSIwithFunctionInDX
56 xchg ax, di
57
58 pop dx
59 pop di
60 ret
61
62
63;--------------------------------------------------------------------
64; String_CopyDSSItoESDIandGetLengthToCX
65; Parameters:
66; DS:SI: Ptr to source NULL terminated string
67; ES:DI: Ptr to destination buffer
68; Returns:
69; CX: Number of characters copied
70; SI,DI: Updated by CX characters
71; Corrupts registers:
72; Nothing
73;--------------------------------------------------------------------
74ALIGN JUMP_ALIGN
75String_CopyDSSItoESDIandGetLengthToCX:
76 push ax
77
78 xor cx, cx
79ALIGN JUMP_ALIGN
80.CopyNextCharacter:
81 lodsb ; Load from DS:SI to AL
82 test al, al ; NULL to end string?
83 jz SHORT .EndOfString
84 stosb ; Store from AL to ES:DI
85 inc cx ; Increment number of characters written
86 jmp SHORT .CopyNextCharacter
87
88ALIGN JUMP_ALIGN
89.EndOfString:
90 pop ax
91 ret
92
93
94;--------------------------------------------------------------------
95; String_GetLengthFromDSSItoCX
96; Parameters:
97; DS:SI: Ptr to NULL terminated string
98; Returns:
99; CX: String length in characters
100; Corrupts registers:
101; Nothing
102;--------------------------------------------------------------------
103ALIGN JUMP_ALIGN
104String_GetLengthFromDSSItoCX:
105 push ax
106 push si
107
108 call Registers_ExchangeDSSIwithESDI
109 xor ax, ax ; Find NULL
110 mov cx, -1 ; Full segment if necessary
111 repne scasb
112 mov cx, di
113 call Registers_ExchangeDSSIwithESDI
114
115 pop si
116 stc
117 sbb cx, si ; Subtract NULL
118 pop ax
119 ret
Note: See TracBrowser for help on using the repository browser.