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

Last change on this file since 363 was 293, checked in by krille_n_@…, 13 years ago

Commit 1/2 (Library, Configurators and Serial Server):

  • Changed Emulate.inc so that making 286 and 386 versions now works. Additionally, only one processor type define is needed in the makefile.
  • Minor optimizations.
  • Fixed spelling and did some cleaning.
File size: 2.8 KB
RevLine 
[41]1; Project name : Assembly Library
2; Description : Functions for handling characters.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
[53]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;--------------------------------------------------------------------
[41]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
[53]37; CX: Number of characters processed
[52]38; SI: Updated
[293]39; CF: Cleared if successful
[52]40; Set if error during conversion
[41]41; Corrupts registers:
[52]42; Nothing
[41]43;--------------------------------------------------------------------
44ALIGN JUMP_ALIGN
45String_ConvertWordToAXfromStringInDSSIwithBaseInBX:
[52]46 push di
47 push dx
[41]48
[52]49 xor di, di
50 mov dx, StringProcess_ConvertToWordInDIWithBaseInBX
51 call StringProcess_DSSIwithFunctionInDX
52 xchg ax, di
[41]53
[52]54 pop dx
55 pop di
[41]56 ret
57
58
59;--------------------------------------------------------------------
[53]60; String_CopyDSSItoESDIandGetLengthToCX
[41]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
[53]71String_CopyDSSItoESDIandGetLengthToCX:
[41]72 push ax
[52]73
[41]74 xor cx, cx
75ALIGN JUMP_ALIGN
[52]76.CopyNextCharacter:
[41]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
[52]82 jmp SHORT .CopyNextCharacter
[41]83
84ALIGN JUMP_ALIGN
85.EndOfString:
86 pop ax
87 ret
[46]88
89
90;--------------------------------------------------------------------
[52]91; String_GetLengthFromDSSItoCX
[46]92; Parameters:
[52]93; DS:SI: Ptr to NULL terminated string
[46]94; Returns:
[52]95; CX: String length in characters
[46]96; Corrupts registers:
97; Nothing
98;--------------------------------------------------------------------
99ALIGN JUMP_ALIGN
[52]100String_GetLengthFromDSSItoCX:
101 push ax
[46]102 push si
103
[54]104 call Registers_ExchangeDSSIwithESDI
[52]105 xor ax, ax ; Find NULL
106 mov cx, -1 ; Full segment if necessary
107 repne scasb
108 mov cx, di
[54]109 call Registers_ExchangeDSSIwithESDI
[46]110
[52]111 pop si
112 stc
113 sbb cx, si ; Subtract NULL
[46]114 pop ax
115 ret
Note: See TracBrowser for help on using the repository browser.