Changeset 52 in xtideuniversalbios for trunk/Assembly_Library/Src/String


Ignore:
Timestamp:
Oct 12, 2010, 6:51:07 PM (14 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Changes to Assembly Library:
Completely rewritten line splitting (slower but no need to modify string).
Some changes to string processing functions.
Saved few bytes from CGA detection.

Location:
trunk/Assembly_Library/Src/String
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Src/String/String.asm

    r46 r52  
    22; Project name  :   Assembly Library
    33; Created date  :   12.7.2010
    4 ; Last update   :   1.10.2010
     4; Last update   :   12.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for handling characters.
     
    1616;   Returns:
    1717;       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
     18;       SI:     Updated
     19;       CF:     Cleared if successfull
     20;               Set if error during conversion
    2121;   Corrupts registers:
    22 ;       DX
     22;       Nothing
    2323;--------------------------------------------------------------------
    2424ALIGN JUMP_ALIGN
    2525String_ConvertWordToAXfromStringInDSSIwithBaseInBX:
    26     xor     dx, dx
    27     cld
     26    push    di
     27    push    dx
    2828
    29 ALIGN 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
     29    xor     di, di
     30    mov     dx, StringProcess_ConvertToWordInDIWithBaseInBX
     31    call    StringProcess_DSSIwithFunctionInDX
     32    xchg    ax, di
    4133
    42 ALIGN JUMP_ALIGN
    43 .InvalidCharacter:
    44     sub     al, 1               ; Set CF if NULL character, clear CF otherwise
    45     xchg    ax, dx              ; Return WORD in AX
     34    pop     dx
     35    pop     di
    4636    ret
    4737
    4838
    4939;--------------------------------------------------------------------
    50 ; String_CopyToESDIfromDSSIwithoutTerminatingESDI
     40; String_CopyDSSItoESDIandGetSizeToCX
    5141;   Parameters:
    5242;       DS:SI:  Ptr to source NULL terminated string
     
    5949;--------------------------------------------------------------------
    6050ALIGN JUMP_ALIGN
    61 String_CopyToESDIfromDSSIwithoutTerminatingESDI:
     51String_CopyDSSItoESDIandGetSizeToCX:
    6252    push    ax
     53
    6354    xor     cx, cx
    64 
    6555ALIGN JUMP_ALIGN
    66 .GetAndStoreNewCharacter:
     56.CopyNextCharacter:
    6757    lodsb                       ; Load from DS:SI to AL
    6858    test    al, al              ; NULL to end string?
     
    7060    stosb                       ; Store from AL to ES:DI
    7161    inc     cx                  ; Increment number of characters written
    72     jmp     SHORT .GetAndStoreNewCharacter
     62    jmp     SHORT .CopyNextCharacter
    7363
    7464ALIGN JUMP_ALIGN
     
    7969
    8070;--------------------------------------------------------------------
    81 ; String_ConvertDSSItoLowerCase
     71; String_GetLengthFromDSSItoCX
    8272;   Parameters:
    83 ;       DS:SI:  Ptr to NULL terminated string to convert
     73;       DS:SI:  Ptr to NULL terminated string
    8474;   Returns:
    85 ;       Nothing
     75;       CX:     String length in characters
    8676;   Corrupts registers:
    8777;       Nothing
    8878;--------------------------------------------------------------------
    8979ALIGN JUMP_ALIGN
    90 String_ConvertDSSItoLowerCase:
     80String_GetLengthFromDSSItoCX:
     81    push    ax
    9182    push    si
    92     push    ax
    9383
    94 ALIGN 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
     84    call    Memory_ExchangeDSSIwithESDI
     85    xor     ax, ax      ; Find NULL
     86    mov     cx, -1      ; Full segment if necessary
     87    repne scasb
     88    mov     cx, di
     89    call    Memory_ExchangeDSSIwithESDI
    10290
    103 ALIGN JUMP_ALIGN
    104 .EndOfString:
     91    pop     si
     92    stc
     93    sbb     cx, si      ; Subtract NULL
    10594    pop     ax
    106     pop     si
    10795    ret
Note: See TracChangeset for help on using the changeset viewer.