Changeset 77 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Libraries/string.asm


Ignore:
Timestamp:
Jan 4, 2011, 10:53:15 PM (13 years ago)
Author:
krille_n_@…
google:author:
krille_n_@hotmail.com
Message:

Minor size optimizations plus a bug fix in print.asm in Print_IntSW (DI was left hanging on the stack if the parameter in AX was positive). Also a very minor speed optimization in keys.asm in Keys_Backspace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/XTIDE_Universal_BIOS/Src/Libraries/string.asm

    r76 r77  
    22; Project name  :   String library
    33; Created date  :   7.10.2009
    4 ; Last update   :   20.12.2009
     4; Last update   :   4.1.2011
    55; Author        :   Tomi Tilli,
    6 ;               :   Krille (optimizations)
     6;               :   Krister Nordvall (optimizations)
    77; Description   :   ASM library to work as Standard C String and Character.
    88
     
    130130String_IsHexDigit:
    131131    call    String_IsAlphaNum   ; Is alphabetic letter or digit?
    132     jc      .CheckHex           ;  If so, jump to check A...F
    133     ret
    134 .CheckHex:
     132    jnc     .ExitStrIsHexDigit  ; If it is, check A...F. If not, exit
    135133    push    ax                  ; Store character
    136134    call    String_ToLower      ; Convert to lower case letter
    137135    cmp     al, 'f'+1           ; Last valid hex alphanumeric?
    138136    pop     ax                  ; Restore character
     137
     138.ExitStrIsHexDigit:
    139139    ret
    140140
     
    165165    mov     ah, al              ; Copy char to AH
    166166    call    String_IsDigit      ; Is '0'...'9'?
    167     jc      .ConvertDigit       ;  If so, jump to convert
     167    jnc     .CheckForAlpha      ; If not, check for alphabetic letter
     168    sub     al, '0'             ; Convert char to integer
     169    jmp     .FinalizeAXAndCheckBase
     170
     171.CheckForAlpha:
    168172    call    String_IsAlpha      ; Is alphabetic letter?
    169     jnc     .RetFalse           ; If not, return FALSE
     173    jnc     .JustRet            ; If not, return FALSE
    170174    call    String_ToLower      ; Convert to lower case
     175    sub     al, 'a'-10          ; From char to integer: a=10, b=11...
     176
     177.FinalizeAXAndCheckBase:
    171178    xchg    al, ah              ; Converted char to AH
    172     sub     ah, 'a'-10          ; From char to integer: a=10, b=11...
    173179    cmp     ah, cl              ; Belongs to base?
    174     jae     .RetFalse           ; If not, return FALSE
    175     stc                         ; Set CF since belongs to base
    176     ret
    177 ALIGN JUMP_ALIGN
    178 .ConvertDigit:
    179     sub     ah, '0'             ; Convert char to integer
    180     cmp     ah, cl              ; Belongs to base?
    181     jae     .RetFalse           ; If not, return FALSE
    182     stc                         ; Set CF since belongs to base
    183     ret
    184 ALIGN JUMP_ALIGN
    185 .RetFalse:
    186     clc                         ; Clear CF since char doesn't belong to b
     180
     181.JustRet:                       ; CF now reflects TRUE/FALSE so just return
    187182    ret
    188183%endif
     
    324319    jnz     .CharLoop           ; Loop while characters left
    325320
    326     mov     ax, bx              ; Copy loword to AX
     321    stc                         ; Set CF since success
     322.RetFalse:  ; If we jumped to here no CLC is needed to reflect a FALSE condition
     323    mov     ax, bx              ; Copy loword to AX (may be incomplete)
    327324    pop     bx                  ; Restore BX
    328325    pop     di                  ; Restore DI
    329326    pop     si                  ; Restore SI
    330327    pop     ds                  ; Restore DS
    331     stc                         ; Set CF since success
    332     ret
    333 ALIGN JUMP_ALIGN
    334 .RetFalse:
    335     mov     ax, bx              ; Copy (likely incomplete) loword to AX
    336     pop     bx                  ; Restore BX
    337     pop     di                  ; Restore DI
    338     pop     si                  ; Restore SI
    339     pop     ds                  ; Restore DS
    340     clc                         ; Clear CF since error
    341328    ret
    342329%endif
     
    448435ALIGN JUMP_ALIGN
    449436.Str2NotFound:
    450     xor     bx, bx              ; Zero BX
     437    xor     bx, bx              ; Zero BX and clear CF
    451438    pop     si                  ; Restore SI
    452439    pop     cx                  ; Restore CX
    453     clc                         ; Clear CF since str2 was not found
    454440    ret
    455441%endif
     
    578564ALIGN JUMP_ALIGN
    579565.ConvComplete:
    580     mov     ax, bx              ; Copy loword to AX
     566    stc                         ; Set CF since success
     567ALIGN JUMP_ALIGN
     568.RetFalse:  ; If we jumped to here no CLC is needed to reflect a FALSE condition
     569    mov     ax, bx              ; Copy loword to AX (may be incomplete)
    581570    pop     bx                  ; Restore BX
    582571    pop     si                  ; Restore SI
    583572    pop     ds                  ; Restore DS
    584     stc                         ; Set CF since success
    585     ret
    586 ALIGN JUMP_ALIGN
    587 .RetFalse:
    588     mov     ax, bx              ; Copy (likely incomplete) loword to AX
    589     pop     bx                  ; Restore BX
    590     pop     si                  ; Restore SI
    591     pop     ds                  ; Restore DS
    592     clc                         ; Clear CF since error
    593573    ret
    594574%endif
Note: See TracChangeset for help on using the changeset viewer.