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

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

Changes to Assembly Library:

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