Changeset 46 in xtideuniversalbios for trunk/Assembly_Library/Src/Util/Memory.asm


Ignore:
Timestamp:
Oct 4, 2010, 7:38:36 AM (14 years ago)
Author:
aitotat
google:author:
aitotat
Message:

Changes to Assembly Library:
Sorting now works (pivot item is copied for comparison and index comparisons are now signed instead of unsigned).
Menu shadow now looks better on black and white modes.
Sorting is now implemented for File Fialog: directories are displayed before files.
File Dialog now displays directories with upper case letters and files with lower case letters.
Line splitter now removes all empty lines from the end.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Assembly_Library/Src/Util/Memory.asm

    r41 r46  
    22; Project name  :   Assembly Library
    33; Created date  :   14.7.2010
    4 ; Last update   :   15.9.2010
     4; Last update   :   1.10.2010
    55; Author        :   Tomi Tilli
    66; Description   :   Functions for memory access.
     
    1010
    1111;--------------------------------------------------------------------
    12 ; Memory_ZeroDSSIbyWordsInCX
     12; OPTIMIZE_STRING_OPERATION
    1313;   Parameters
    14 ;       CX:     Number of words to zero
    15 ;       DS:SI:  Ptr to buffer to zero
     14;       %1:     Repeat instruction
     15;       %2:     String instruction without size (for example MOVS and not MOVSB or MOVSW)
     16;       CX:     Number of BYTEs to operate
     17;       DS:SI:  Ptr to source data
     18;       ES:DI:  Ptr to destination
    1619;   Returns:
     20;       SI, DI: Updated by number of bytes operated
     21;   Corrupts registers:
    1722;       Nothing
     23;--------------------------------------------------------------------
     24%macro OPTIMIZE_STRING_OPERATION 2
     25    push    cx
     26
     27    shr     cx, 1           ; Operate with WORDs for performance
     28    jcxz    %%HandleRemainingByte
     29    %1      %2w
     30%%HandleRemainingByte:
     31    jnc     SHORT %%OperationCompleted
     32    %2b
     33
     34ALIGN JUMP_ALIGN
     35%%OperationCompleted:
     36    pop     cx
     37%endmacro
     38
     39
     40;--------------------------------------------------------------------
     41; Memory_CopyCXbytesFromDSSItoESDI
     42;   Parameters
     43;       CX:     Number of bytes to copy
     44;       DS:SI:  Ptr to source data
     45;       ES:DI:  Ptr to destination buffer
     46;   Returns:
     47;       SI, DI: Updated by number of bytes copied
    1848;   Corrupts registers:
    19 ;       AX
     49;       Nothing
    2050;--------------------------------------------------------------------
    2151ALIGN JUMP_ALIGN
    22 Memory_ZeroDSSIbyWordsInCX:
    23     call    Memory_ExchangeDSSIwithESDI
    24     call    Memory_ZeroESDIbyWordsInCX
    25     jmp     SHORT Memory_ExchangeDSSIwithESDI
     52Memory_CopyCXbytesFromDSSItoESDI:
     53    OPTIMIZE_STRING_OPERATION rep, movs
     54    ret
     55
    2656
    2757;--------------------------------------------------------------------
    28 ; Memory_ZeroSSBPbyWordsInCX
     58; Memory_ZeroSSBPwithSizeInCX
    2959;   Parameters
    30 ;       CX:     Number of words to zero
     60;       CX:     Number of bytes to zero
    3161;       SS:BP:  Ptr to buffer to zero
    3262;   Returns:
     
    3666;--------------------------------------------------------------------
    3767ALIGN JUMP_ALIGN
    38 Memory_ZeroSSBPbyWordsInCX:
    39     push    es
    40     push    di
     68Memory_ZeroSSBPwithSizeInCX:
    4169    push    ax
    4270
    43     push    ss
    44     pop     es
    45     mov     di, bp
    46     call    Memory_ZeroESDIbyWordsInCX
     71    call    Memory_ExchangeSSBPwithESDI
     72    call    Memory_ZeroESDIwithSizeInCX
     73    call    Memory_ExchangeSSBPwithESDI
    4774
    4875    pop     ax
    49     pop     di
    50     pop     es
    5176    ret
    5277
    5378;--------------------------------------------------------------------
    54 ; Memory_ZeroESDIbyWordsInCX
     79; Memory_ZeroESDIwithSizeInCX
    5580;   Parameters
    56 ;       CX:     Number of words to zero
    57 ;       ES:DI:  Ptr to buffer to zero
     81;       CX:     Number of bytes to zero
     82;       ES:DI:  Ptr to destination buffer
    5883;   Returns:
    5984;       Nothing
     
    6287;--------------------------------------------------------------------
    6388ALIGN JUMP_ALIGN
    64 Memory_ZeroESDIbyWordsInCX:
     89Memory_ZeroESDIwithSizeInCX:
    6590    xor     ax, ax
    66     ; Fall to Memory_FillESDIwithAXbyCXtimes
     91    ; Fall to Memory_StoreCXbytesFromAccumToESDI
    6792
    6893;--------------------------------------------------------------------
    69 ; Memory_FillESDIwithAXbyCXtimes
     94; Memory_StoreCXbytesFromAccumToESDI
    7095;   Parameters
    7196;       AX:     Word to use to fill buffer
    72 ;       CX:     Number of words to fill
    73 ;       ES:DI:  Ptr to buffer to fill
     97;       CX:     Number of BYTEs to store
     98;       ES:DI:  Ptr to destination buffer
    7499;   Returns:
    75100;       Nothing
     
    78103;--------------------------------------------------------------------
    79104ALIGN JUMP_ALIGN
    80 Memory_FillESDIwithAXbyCXtimes:
    81     cld
    82     push    di
    83     push    cx
    84     rep stosw
    85     pop     cx
    86     pop     di
     105Memory_StoreCXbytesFromAccumToESDI:
     106    OPTIMIZE_STRING_OPERATION rep, stos
     107    sub     di, cx
    87108    ret
    88109
    89110
    90111;--------------------------------------------------------------------
     112; Memory_ExchangeSSBPwithESDI
    91113; Memory_ExchangeDSSIwithESDI
    92114;   Parameters
    93115;       Nothing
    94116;   Returns:
    95 ;       DS:SI and ES:DI are exchanged.
     117;       SS:BP/DS:SI and ES:DI are exchanged.
    96118;   Corrupts registers:
    97119;       Nothing
    98120;--------------------------------------------------------------------
     121ALIGN JUMP_ALIGN
     122Memory_ExchangeSSBPwithESDI:
     123    xchg    bp, di
     124    push    ss
     125    push    es
     126    pop     ss
     127    pop     es
     128    ret
     129
    99130ALIGN JUMP_ALIGN
    100131Memory_ExchangeDSSIwithESDI:
     
    108139
    109140;--------------------------------------------------------------------
    110 ; Memory_CopySSBPtoDSSI
    111141; Memory_CopySSBPtoESDI
    112142;   Parameters
    113143;       Nothing
    114144;   Returns:
    115 ;       DS:SI:      Same as SS:BP
     145;       ES:DI:      Same as SS:BP
    116146;   Corrupts registers:
    117147;       Nothing
    118148;--------------------------------------------------------------------
    119 ALIGN JUMP_ALIGN
    120 Memory_CopySSBPtoDSSI:
    121     push    ss
    122     pop     ds
    123     mov     si, bp
    124     ret
    125 
    126149ALIGN JUMP_ALIGN
    127150Memory_CopySSBPtoESDI:
Note: See TracChangeset for help on using the changeset viewer.