Changeset 77 in xtideuniversalbios


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.

Location:
trunk/XTIDE_Universal_BIOS/Src/Libraries
Files:
5 edited

Legend:

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

    r3 r77  
    22; Project name  :   Keyboard library
    33; Created date  :   17.11.2009
    4 ; Last update   :   31.12.2009
    5 ; Author        :   Tomi Tilli
     4; Last update   :   4.1.2011
     5; Author        :   Tomi Tilli,
     6;               :   Krister Nordvall (optimizations)
    67; Description   :   ASM library to for keyboard related functions.     
    78
     
    311312ALIGN JUMP_ALIGN
    312313Keys_Backspace:
    313     push    dx
    314314    test    si, si              ; At the beginning?
    315315    jz      .Return             ;  If so, return
     316    push    dx                  ; Save DX
    316317    dec     si                  ; Decrement char counter
    317318    dec     di                  ; Decrement offset to buffer
     
    322323    mov     dl, BS              ; Back again
    323324    PRINT_CHAR
     325    pop     dx                  ; Restore DX
    324326ALIGN JUMP_ALIGN
    325327.Return:
    326     pop     dx
    327     ret
    328 %endif
     328    ret
     329%endif
  • trunk/XTIDE_Universal_BIOS/Src/Libraries/math.asm

    r3 r77  
    22; Project name  :   Math library
    33; Created date  :   7.10.2009
    4 ; Last update   :   1.1.2010
    5 ; Author        :   Tomi Tilli
     4; Last update   :   4.1.2011
     5; Author        :   Tomi Tilli,
     6;               :   Krister Nordvall (optimizations)
    67; Description   :   ASM library to for math related functions.     
    78
     
    122123.RetZero:                       ; Return 0 in DX:AX
    123124    xor     ax, ax
    124     xor     dx, dx
     125    cwd
    125126    ret
    126127%endif
     
    143144ALIGN JUMP_ALIGN
    144145Math_DivDWbyW:
    145     mov     bx, ax
    146     mov     ax, dx
    147     xor     dx, dx
     146    xor     bx, bx
     147    xchg    bx, ax
     148    xchg    dx, ax
    148149    div     cx
    149150    xchg    ax, bx
     
    171172    push    cx
    172173    push    ax
    173     mov     ax, cx              ; Copy divisor to AX
    174     mov     cl, 10              ; Load 10 to CL
     174    mov     al, 10              ; Load 10 to AL
     175    xchg    cx, ax              ; AX = Divisor CL = 10
    175176    div     cl                  ; AL = Divisor divided by 10
    176177    inc     ax                  ; Increment to compensate new remainder
  • trunk/XTIDE_Universal_BIOS/Src/Libraries/menu/menudraw.asm

    r10 r77  
    22; Project name  :   Menu library
    33; Created date  :   9.11.2009
    4 ; Last update   :   25.5.2010
    5 ; Author        :   Tomi Tilli
     4; Last update   :   4.1.2011
     5; Author        :   Tomi Tilli,
     6;               :   Krister Nordvall (optimizations)
    67; Description   :   ASM library to menu system.
    78;                   Contains menu drawing functions.
     
    4142    mov     al, CNT_SCRN_ROW            ; Load row count
    4243    mul     ah                          ; AX=Column count * row count
    43     mov     cx, ax                      ; Copy char count to CX
     44    mov     cx, 0920h                   ; Write Char and attr, space char
    4445    mov     bx, ATTR_MDA_NORMAL         ; Page zero, normal attribute
    45     mov     ax, 0920h                   ; Write Char and attr, space char
     46    xchg    cx, ax                      ; CX=Char count AX=Space char and attr
    4647    int     10h
    4748    ret
     
    354355ALIGN JUMP_ALIGN
    355356MenuDraw_TopBorder:
    356     mov     bh, B_TL
    357     mov     bl, B_H
     357    mov     bx, (B_TL << 8) + B_H
    358358    mov     dh, B_TR
    359359    jmp     SHORT MenuDraw_BorderChars
     
    361361ALIGN JUMP_ALIGN
    362362MenuDraw_StringBorder:
    363     mov     bh, B_V
    364     mov     bl, ' '
     363    mov     bx, (B_V << 8) + ' '
    365364    mov     dh, B_V
    366365    jmp     SHORT MenuDraw_BorderChars
     
    369368MenuDraw_ScrollBorder:
    370369    call    MenuDraw_GetScrollChar          ; Load scroll char to DH
    371     mov     bh, B_V
    372     mov     bl, ' '
     370    mov     bx, (B_V << 8) + ' '
    373371    jmp     SHORT MenuDraw_BorderChars
    374372
    375373ALIGN JUMP_ALIGN
    376374MenuDraw_MiddleBorder:
    377     mov     bh, BVL_THR
    378     mov     bl, T_H
     375    mov     bx, (BVL_THR << 8) + T_H
    379376    mov     dh, THL_BVR
    380377
     
    393390ALIGN JUMP_ALIGN
    394391MenuDraw_BottomBorder:
    395     mov     bh, B_LL
    396     mov     bl, B_H
     392    mov     bx, (B_LL << 8) + B_H
    397393    mov     dh, B_LR
    398394    cmp     WORD [bp+MENUVARS.wTimeInit], 0 ; Timeout enabled?
  • trunk/XTIDE_Universal_BIOS/Src/Libraries/print.asm

    r3 r77  
    22; Project name  :   Print library
    33; Created date  :   6.10.2009
    4 ; Last update   :   31.12.2009
    5 ; Author        :   Tomi Tilli
    6 ; Description   :   ASM library to for character and string
     4; Last update   :   4.1.2011
     5; Author        :   Tomi Tilli,
     6;               :   Krister Nordvall (optimizations)
     7; Description   :   ASM library for character and string
    78;                   printing related functions.
    89
     
    467468ALIGN JUMP_ALIGN
    468469Print_IntSW:
     470    test    ax, ax              ; Positive integer?
     471    jns     Print_IntUW         ;  If so, jump to print it
    469472    push    di                  ; Store DI
    470     cmp     ax, 0               ; Positive integer?
    471     jge     Print_IntUW         ;  If so, jump to print it
    472473    push    ax                  ; Store word
    473474    mov     dl, '-'             ; Print '-'
  • 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.