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

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

Changes to Assembly Library:
Sorting now works (pivot item is copied for comparison and index comparisons are now signed instead of unsigned).
Menu shadow now looks better on black and white modes.
Sorting is now implemented for File Fialog: directories are displayed before files.
File Dialog now displays directories with upper case letters and files with lower case letters.
Line splitter now removes all empty lines from the end.

File size: 2.8 KB
RevLine 
[41]1; File name : String.asm
2; Project name : Assembly Library
3; Created date : 12.7.2010
[46]4; Last update : 1.10.2010
[41]5; Author : Tomi Tilli
6; Description : Functions for handling characters.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; String_ConvertWordToAXfromStringInDSSIwithBaseInBX
13; Parameters:
14; BX: Numeric base (10 or 16)
15; DS:SI: Ptr to string to convert
16; Returns:
17; AX: Word converted from string
18; DI: Offset to NULL or first invalid character
19; CF: Set if conversion successfull
20; Cleared if invalid string
21; Corrupts registers:
22; DX
23;--------------------------------------------------------------------
24ALIGN JUMP_ALIGN
25String_ConvertWordToAXfromStringInDSSIwithBaseInBX:
26 xor dx, dx
27 cld
28
29ALIGN JUMP_ALIGN
30.ConvertWordToAXfromStringInDSSIwithBaseInBX:
31 lodsb ; Load character from DS:SI to AL
32 call Char_ConvertIntegerToALfromDigitInALwithBaseInBX
33 jnc SHORT .InvalidCharacter
34 xor ah, ah
35 push ax ; Push integer
36 xchg ax, dx ; Copy WORD to AX
37 mul bx ; DX:AX = word in AX * base in BX
38 pop dx ; Pop integer
39 add dx, ax ; WORD back to DX
40 jmp SHORT .ConvertWordToAXfromStringInDSSIwithBaseInBX
41
42ALIGN JUMP_ALIGN
43.InvalidCharacter:
44 sub al, 1 ; Set CF if NULL character, clear CF otherwise
45 xchg ax, dx ; Return WORD in AX
46 ret
47
48
49;--------------------------------------------------------------------
50; String_CopyToESDIfromDSSIwithoutTerminatingESDI
51; Parameters:
52; DS:SI: Ptr to source NULL terminated string
53; ES:DI: Ptr to destination buffer
54; Returns:
55; CX: Number of characters copied
56; SI,DI: Updated by CX characters
57; Corrupts registers:
58; Nothing
59;--------------------------------------------------------------------
60ALIGN JUMP_ALIGN
61String_CopyToESDIfromDSSIwithoutTerminatingESDI:
62 push ax
63 xor cx, cx
64
65ALIGN JUMP_ALIGN
66.GetAndStoreNewCharacter:
67 lodsb ; Load from DS:SI to AL
68 test al, al ; NULL to end string?
69 jz SHORT .EndOfString
70 stosb ; Store from AL to ES:DI
71 inc cx ; Increment number of characters written
72 jmp SHORT .GetAndStoreNewCharacter
73
74ALIGN JUMP_ALIGN
75.EndOfString:
76 pop ax
77 ret
[46]78
79
80;--------------------------------------------------------------------
81; String_ConvertDSSItoLowerCase
82; Parameters:
83; DS:SI: Ptr to NULL terminated string to convert
84; Returns:
85; Nothing
86; Corrupts registers:
87; Nothing
88;--------------------------------------------------------------------
89ALIGN JUMP_ALIGN
90String_ConvertDSSItoLowerCase:
91 push si
92 push ax
93
94ALIGN JUMP_ALIGN
95.ConvertNextCharacter:
96 lodsb
97 test al, al ; NULL to end string?
98 jz SHORT .EndOfString
99 call Char_ALtoLowerCaseLetter
100 mov [si-1], al
101 jmp SHORT .ConvertNextCharacter
102
103ALIGN JUMP_ALIGN
104.EndOfString:
105 pop ax
106 pop si
107 ret
Note: See TracBrowser for help on using the repository browser.