source: xtideuniversalbios/trunk/Assembly_Library/Src/String/StringProcess.asm @ 369

Last change on this file since 369 was 369, checked in by gregli@…, 12 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.9 KB
Line 
1; Project name  :   Assembly Library
2; Description   :   Functions for processing characters in a string.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Character processing callback function prototype for StringProcess_DSSIwithFunctionInDX.
9;   Parameters:
10;       AL:         Character to process
11;       CX:         Character number (index for next character)
12;       DS:SI:      Ptr to next character
13;       BX,DI,ES:   Free to use by processing function
14;   Returns:
15;       CF:         Clear to continue with next character
16;                   Set to stop processing
17;       BX,DI,ES:   Free to use by processing function
18;   Corrupts registers:
19;       AX
20;--------------------------------------------------------------------
21
22
23;--------------------------------------------------------------------
24; StringProcess_DSSIwithFunctionInDX
25;   Parameters:
26;       DX:     Character processing function
27;       DS:SI:  Ptr to NULL terminated string to convert
28;   Returns:
29;       CX:     Number of characters processed
30;       CF:     Clear if all characters processed
31;               Set if terminated by processing function
32;   Corrupts registers:
33;       Nothing (processing function can corrupt BX,DI,ES)
34;--------------------------------------------------------------------
35ALIGN STRING_JUMP_ALIGN
36StringProcess_DSSIwithFunctionInDX:
37    push    si
38    push    ax
39
40    xor     cx, cx
41ALIGN STRING_JUMP_ALIGN
42.ProcessNextCharacter:
43    lodsb
44    test    al, al              ; NULL to end string
45    jz      SHORT .EndOfString  ; Return with CF cleared
46    inc     cx
47    call    dx
48    jnc     SHORT .ProcessNextCharacter
49
50ALIGN STRING_JUMP_ALIGN
51.EndOfString:
52    pop     ax
53    pop     si
54    ret
55
56
57;--------------------------------------------------------------------
58; StringProcess_ConvertToLowerCase (callback function for StringProcess_DSSIwithFunctionInDX)
59;   Parameters:
60;       AL:     Character to convert to lower case
61;       DS:SI:  Ptr to next character
62;   Returns:
63;       CF:     Clear to continue processing
64;   Corrupts registers:
65;       AL
66;--------------------------------------------------------------------
67ALIGN STRING_JUMP_ALIGN
68StringProcess_ConvertToLowerCase:
69    call    Char_ALtoLowerCaseLetter
70    mov     [si-1], al
71    clc
72    ret
73
74
75;--------------------------------------------------------------------
76; StringProcess_ConvertToWordInDIWithBaseInBX (callback function for StringProcess_DSSIwithFunctionInDX)
77;   Parameters:
78;       AL:     Character to convert to lower case
79;       BX:     Numeric base (2, 10 or 16)
80;   Returns:
81;       CF:     Clear to continue processing
82;               Set if error
83;   Corrupts registers:
84;       AX
85;--------------------------------------------------------------------
86ALIGN STRING_JUMP_ALIGN
87StringProcess_ConvertToWordInDIWithBaseInBX:
88    call    Char_ConvertIntegerToALfromDigitInALwithBaseInBX
89    cmc
90    jc      SHORT .InvalidCharacter
91    push    dx
92
93    xor     ah, ah      ; Digit converted to integer now in AX
94    xchg    ax, di
95    mul     bx          ; Old WORD *= base
96    jc      SHORT .Overflow
97    add     di, ax      ; Add old WORD to new integer
98
99.Overflow:
100    pop     dx
101.InvalidCharacter:
102    ret
Note: See TracBrowser for help on using the repository browser.