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

Last change on this file since 376 was 376, checked in by gregli@…, 12 years ago

WIDE checkin... Added copyright and license information to sorce files, as per the GPL instructions for usage.

File size: 3.5 KB
RevLine 
[41]1; Project name  :   Assembly Library
2; Description   :   Functions for handling characters.
3
[376]4;
5; XTIDE Universal BIOS and Associated Tools 
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12; 
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16; GNU General Public License for more details.     
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;       
19
[41]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
[53]24; String_ConvertDSSItoLowerCase
25;   Parameters:
26;       DS:SI:  Ptr to string to convert
27;   Returns:
28;       CX:     Number of characters processed
29;       SI:     Updated
30;   Corrupts registers:
31;       Nothing
32;--------------------------------------------------------------------
[369]33ALIGN STRING_JUMP_ALIGN
[53]34String_ConvertDSSItoLowerCase:
35    push    dx
36    push    ax
37
38    mov     dx, StringProcess_ConvertToLowerCase
39    call    StringProcess_DSSIwithFunctionInDX
40
41    pop     ax
42    pop     dx
43    ret
44
45
46;--------------------------------------------------------------------
[41]47; String_ConvertWordToAXfromStringInDSSIwithBaseInBX
48;   Parameters:
49;       BX:     Numeric base (10 or 16)
50;       DS:SI:  Ptr to string to convert
51;   Returns:
52;       AX:     Word converted from string
[53]53;       CX:     Number of characters processed
[52]54;       SI:     Updated
[293]55;       CF:     Cleared if successful
[52]56;               Set if error during conversion
[41]57;   Corrupts registers:
[52]58;       Nothing
[41]59;--------------------------------------------------------------------
[369]60ALIGN STRING_JUMP_ALIGN
[41]61String_ConvertWordToAXfromStringInDSSIwithBaseInBX:
[52]62    push    di
63    push    dx
[41]64
[52]65    xor     di, di
66    mov     dx, StringProcess_ConvertToWordInDIWithBaseInBX
67    call    StringProcess_DSSIwithFunctionInDX
68    xchg    ax, di
[41]69
[52]70    pop     dx
71    pop     di
[41]72    ret
73
74
75;--------------------------------------------------------------------
[53]76; String_CopyDSSItoESDIandGetLengthToCX
[41]77;   Parameters:
78;       DS:SI:  Ptr to source NULL terminated string
79;       ES:DI:  Ptr to destination buffer
80;   Returns:
81;       CX:     Number of characters copied
82;       SI,DI:  Updated by CX characters
83;   Corrupts registers:
84;       Nothing
85;--------------------------------------------------------------------
[369]86ALIGN STRING_JUMP_ALIGN
[53]87String_CopyDSSItoESDIandGetLengthToCX:
[41]88    push    ax
[52]89
[41]90    xor     cx, cx
[369]91ALIGN STRING_JUMP_ALIGN
[52]92.CopyNextCharacter:
[41]93    lodsb                       ; Load from DS:SI to AL
94    test    al, al              ; NULL to end string?
95    jz      SHORT .EndOfString
96    stosb                       ; Store from AL to ES:DI
97    inc     cx                  ; Increment number of characters written
[52]98    jmp     SHORT .CopyNextCharacter
[41]99
[369]100ALIGN STRING_JUMP_ALIGN
[41]101.EndOfString:
102    pop     ax
103    ret
[46]104
105
106;--------------------------------------------------------------------
[52]107; String_GetLengthFromDSSItoCX
[46]108;   Parameters:
[52]109;       DS:SI:  Ptr to NULL terminated string
[46]110;   Returns:
[52]111;       CX:     String length in characters
[46]112;   Corrupts registers:
113;       Nothing
114;--------------------------------------------------------------------
[369]115ALIGN STRING_JUMP_ALIGN
[52]116String_GetLengthFromDSSItoCX:
117    push    ax
[46]118    push    si
119
[54]120    call    Registers_ExchangeDSSIwithESDI
[52]121    xor     ax, ax      ; Find NULL
122    mov     cx, -1      ; Full segment if necessary
123    repne scasb
124    mov     cx, di
[54]125    call    Registers_ExchangeDSSIwithESDI
[46]126
[52]127    pop     si
128    stc
129    sbb     cx, si      ; Subtract NULL
[46]130    pop     ax
131    ret
Note: See TracBrowser for help on using the repository browser.