Changeset 46 in xtideuniversalbios for trunk/Assembly_Library/Src/Util/Memory.asm
- Timestamp:
- Oct 4, 2010, 7:38:36 AM (14 years ago)
- google:author:
- aitotat
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Assembly_Library/Src/Util/Memory.asm
r41 r46 2 2 ; Project name : Assembly Library 3 3 ; Created date : 14.7.2010 4 ; Last update : 1 5.9.20104 ; Last update : 1.10.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Functions for memory access. … … 10 10 11 11 ;-------------------------------------------------------------------- 12 ; Memory_ZeroDSSIbyWordsInCX12 ; OPTIMIZE_STRING_OPERATION 13 13 ; 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 16 19 ; Returns: 20 ; SI, DI: Updated by number of bytes operated 21 ; Corrupts registers: 17 22 ; 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 34 ALIGN 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 18 48 ; Corrupts registers: 19 ; AX49 ; Nothing 20 50 ;-------------------------------------------------------------------- 21 51 ALIGN JUMP_ALIGN 22 Memory_ ZeroDSSIbyWordsInCX:23 call Memory_ExchangeDSSIwithESDI24 call Memory_ZeroESDIbyWordsInCX25 jmp SHORT Memory_ExchangeDSSIwithESDI 52 Memory_CopyCXbytesFromDSSItoESDI: 53 OPTIMIZE_STRING_OPERATION rep, movs 54 ret 55 26 56 27 57 ;-------------------------------------------------------------------- 28 ; Memory_ZeroSSBP byWordsInCX58 ; Memory_ZeroSSBPwithSizeInCX 29 59 ; Parameters 30 ; CX: Number of words to zero60 ; CX: Number of bytes to zero 31 61 ; SS:BP: Ptr to buffer to zero 32 62 ; Returns: … … 36 66 ;-------------------------------------------------------------------- 37 67 ALIGN JUMP_ALIGN 38 Memory_ZeroSSBPbyWordsInCX: 39 push es 40 push di 68 Memory_ZeroSSBPwithSizeInCX: 41 69 push ax 42 70 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 47 74 48 75 pop ax 49 pop di50 pop es51 76 ret 52 77 53 78 ;-------------------------------------------------------------------- 54 ; Memory_ZeroESDI byWordsInCX79 ; Memory_ZeroESDIwithSizeInCX 55 80 ; Parameters 56 ; CX: Number of words to zero57 ; ES:DI: Ptr to buffer to zero81 ; CX: Number of bytes to zero 82 ; ES:DI: Ptr to destination buffer 58 83 ; Returns: 59 84 ; Nothing … … 62 87 ;-------------------------------------------------------------------- 63 88 ALIGN JUMP_ALIGN 64 Memory_ZeroESDI byWordsInCX:89 Memory_ZeroESDIwithSizeInCX: 65 90 xor ax, ax 66 ; Fall to Memory_ FillESDIwithAXbyCXtimes91 ; Fall to Memory_StoreCXbytesFromAccumToESDI 67 92 68 93 ;-------------------------------------------------------------------- 69 ; Memory_ FillESDIwithAXbyCXtimes94 ; Memory_StoreCXbytesFromAccumToESDI 70 95 ; Parameters 71 96 ; AX: Word to use to fill buffer 72 ; CX: Number of words to fill73 ; ES:DI: Ptr to buffer to fill97 ; CX: Number of BYTEs to store 98 ; ES:DI: Ptr to destination buffer 74 99 ; Returns: 75 100 ; Nothing … … 78 103 ;-------------------------------------------------------------------- 79 104 ALIGN JUMP_ALIGN 80 Memory_FillESDIwithAXbyCXtimes: 81 cld 82 push di 83 push cx 84 rep stosw 85 pop cx 86 pop di 105 Memory_StoreCXbytesFromAccumToESDI: 106 OPTIMIZE_STRING_OPERATION rep, stos 107 sub di, cx 87 108 ret 88 109 89 110 90 111 ;-------------------------------------------------------------------- 112 ; Memory_ExchangeSSBPwithESDI 91 113 ; Memory_ExchangeDSSIwithESDI 92 114 ; Parameters 93 115 ; Nothing 94 116 ; Returns: 95 ; DS:SI and ES:DI are exchanged.117 ; SS:BP/DS:SI and ES:DI are exchanged. 96 118 ; Corrupts registers: 97 119 ; Nothing 98 120 ;-------------------------------------------------------------------- 121 ALIGN JUMP_ALIGN 122 Memory_ExchangeSSBPwithESDI: 123 xchg bp, di 124 push ss 125 push es 126 pop ss 127 pop es 128 ret 129 99 130 ALIGN JUMP_ALIGN 100 131 Memory_ExchangeDSSIwithESDI: … … 108 139 109 140 ;-------------------------------------------------------------------- 110 ; Memory_CopySSBPtoDSSI111 141 ; Memory_CopySSBPtoESDI 112 142 ; Parameters 113 143 ; Nothing 114 144 ; Returns: 115 ; DS:SI: Same as SS:BP145 ; ES:DI: Same as SS:BP 116 146 ; Corrupts registers: 117 147 ; Nothing 118 148 ;-------------------------------------------------------------------- 119 ALIGN JUMP_ALIGN120 Memory_CopySSBPtoDSSI:121 push ss122 pop ds123 mov si, bp124 ret125 126 149 ALIGN JUMP_ALIGN 127 150 Memory_CopySSBPtoESDI:
Note:
See TracChangeset
for help on using the changeset viewer.