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

Last change on this file since 373 was 369, checked in by gregli@…, 13 years ago

Removed align directives for initalization code and added define for align in boot-time calls to the assembly library (defaulting to 1), resulting in a significant savings for the AT and 386 builds. Fixed a bug with switch command line handling in the serial server. Put in CR characters in licesnse.txt, so that it properly displays on Windows. In the configurator, added default values for user supplied CHS and LBA values, defaulting to values within range when those features are enabled. Updated the copyright message in the configurator as the literal word Copyright is important.

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;--------------------------------------------------------------------
[369]17ALIGN STRING_JUMP_ALIGN
[53]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;--------------------------------------------------------------------
[369]44ALIGN STRING_JUMP_ALIGN
[41]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;--------------------------------------------------------------------
[369]70ALIGN STRING_JUMP_ALIGN
[53]71String_CopyDSSItoESDIandGetLengthToCX:
[41]72 push ax
[52]73
[41]74 xor cx, cx
[369]75ALIGN STRING_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
[369]84ALIGN STRING_JUMP_ALIGN
[41]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;--------------------------------------------------------------------
[369]99ALIGN STRING_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.