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

Last change on this file since 125 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
RevLine 
[41]1; File name : String.asm
2; Project name : Assembly Library
3; Created date : 12.7.2010
[54]4; Last update : 24.10.2010
[41]5; Author : Tomi Tilli
6; Description : Functions for handling characters.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
[53]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;--------------------------------------------------------------------
[41]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
[53]41; CX: Number of characters processed
[52]42; SI: Updated
43; CF: Cleared if successfull
44; Set if error during conversion
[41]45; Corrupts registers:
[52]46; Nothing
[41]47;--------------------------------------------------------------------
48ALIGN JUMP_ALIGN
49String_ConvertWordToAXfromStringInDSSIwithBaseInBX:
[52]50 push di
51 push dx
[41]52
[52]53 xor di, di
54 mov dx, StringProcess_ConvertToWordInDIWithBaseInBX
55 call StringProcess_DSSIwithFunctionInDX
56 xchg ax, di
[41]57
[52]58 pop dx
59 pop di
[41]60 ret
61
62
63;--------------------------------------------------------------------
[53]64; String_CopyDSSItoESDIandGetLengthToCX
[41]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
[53]75String_CopyDSSItoESDIandGetLengthToCX:
[41]76 push ax
[52]77
[41]78 xor cx, cx
79ALIGN JUMP_ALIGN
[52]80.CopyNextCharacter:
[41]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
[52]86 jmp SHORT .CopyNextCharacter
[41]87
88ALIGN JUMP_ALIGN
89.EndOfString:
90 pop ax
91 ret
[46]92
93
94;--------------------------------------------------------------------
[52]95; String_GetLengthFromDSSItoCX
[46]96; Parameters:
[52]97; DS:SI: Ptr to NULL terminated string
[46]98; Returns:
[52]99; CX: String length in characters
[46]100; Corrupts registers:
101; Nothing
102;--------------------------------------------------------------------
103ALIGN JUMP_ALIGN
[52]104String_GetLengthFromDSSItoCX:
105 push ax
[46]106 push si
107
[54]108 call Registers_ExchangeDSSIwithESDI
[52]109 xor ax, ax ; Find NULL
110 mov cx, -1 ; Full segment if necessary
111 repne scasb
112 mov cx, di
[54]113 call Registers_ExchangeDSSIwithESDI
[46]114
[52]115 pop si
116 stc
117 sbb cx, si ; Subtract NULL
[46]118 pop ax
119 ret
Note: See TracBrowser for help on using the repository browser.