Changeset 592 in xtideuniversalbios for trunk/Assembly_Library/Src/Util
- Timestamp:
- Jun 25, 2018, 10:29:27 PM (6 years ago)
- Location:
- trunk/Assembly_Library/Src/Util
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Assembly_Library/Src/Util/Bit.asm
r526 r592 24 24 ; Bit_GetSetCountToCXfromDXAX 25 25 ; Parameters 26 ; DX:AX: 26 ; DX:AX: Source DWORD 27 27 ; Returns: 28 28 ; CX: Number of bits set in DX:AX … … 58 58 push ax 59 59 60 xor cx, cx60 mov cx, -1 61 61 ALIGN JUMP_ALIGN 62 .BitScanLoop: 62 .IncrementCX: 63 inc cx 64 .ShiftLoop: 63 65 shr ax, 1 64 jz SHORT .LastBitInCF 65 adc cl, ch 66 jmp SHORT .BitScanLoop 67 ALIGN JUMP_ALIGN 68 .LastBitInCF: 69 adc cl, ch 66 jc SHORT .IncrementCX 67 jnz SHORT .ShiftLoop 70 68 71 69 pop ax … … 95 93 ret 96 94 95 97 96 ;-------------------------------------------------------------------- 98 97 ; Bit_SetToAXfromIndexInCL … … 115 114 pop dx 116 115 ret 116 -
trunk/Assembly_Library/Src/Util/Math.asm
r589 r592 33 33 ; AX 34 34 ;-------------------------------------------------------------------- 35 %ifndef EXCLUDE_FROM_XTIDE _UNIVERSAL_BIOS OR EXCLUDE_FROM_XTIDECFG35 %ifndef EXCLUDE_FROM_XTIDECFG 36 36 ALIGN JUMP_ALIGN 37 37 Math_DivQWatSSBPbyCX: 38 %if 139 xor dx, dx40 mov ax, [bp+6] ; Load highest divident WORD to DX:AX41 div cx42 mov [bp+6], ax ; Store quotient43 44 mov ax, [bp+4]45 div cx46 mov [bp+4], ax47 48 mov ax, [bp+2]49 div cx50 mov [bp+2], ax51 52 mov ax, [bp]53 div cx54 mov [bp], ax55 ret56 %else ; ~157 ; This is about half the size compared to the above code but it's not tested which is why it's commented away.58 38 push di 59 39 mov di, 6 … … 65 45 dec di 66 46 dec di 67 jns .Next47 jns SHORT .Next 68 48 pop di 69 49 ret 70 %endif ; 171 50 %endif 72 51 … … 83 62 ; Nothing 84 63 ;-------------------------------------------------------------------- 85 %ifndef EXCLUDE_FROM_XTIDECFG 64 %ifndef EXCLUDE_FROM_XTIDECFG OR EXCLUDE_FROM_BIOSDRVS 86 65 ALIGN JUMP_ALIGN 87 66 Math_DivDXAXbyCX: -
trunk/Assembly_Library/Src/Util/Memory.asm
r580 r592 24 24 ; OPTIMIZE_STRING_OPERATION 25 25 ; Parameters 26 ; %1: Repeat instruction 27 ; %2: String instruction without size (for example MOVS and not MOVSB or MOVSW) 26 ; %1: String instruction without size (only MOVS and STOS is supported) 28 27 ; CX: Number of BYTEs to operate 29 ; DS:SI: Ptr to source data 28 ; DS:SI: Ptr to source data (for MOVS) 30 29 ; ES:DI: Ptr to destination 31 30 ; Returns: 31 ; CF: Cleared 32 ; CX: Zero 32 33 ; SI, DI: Updated by number of bytes operated 33 34 ; Corrupts registers: 34 35 ; Nothing 35 36 ;-------------------------------------------------------------------- 36 %macro OPTIMIZE_STRING_OPERATION 2 37 push cx 38 39 shr cx, 1 ; Operate with WORDs for performance 40 jz %%HandleRemainingByte 41 %1 %2w 42 %%HandleRemainingByte: 43 jnc SHORT %%OperationCompleted 44 %2b 45 46 ALIGN JUMP_ALIGN 47 %%OperationCompleted: 48 pop cx 37 %macro OPTIMIZE_STRING_OPERATION 1 38 shr cx, 1 39 rep %1w 40 eRCL_IM cx, 1 41 rep %1b 49 42 %endmacro 50 43 … … 57 50 ; ES:DI: Ptr to destination buffer 58 51 ; Returns: 52 ; CF: Cleared 59 53 ; SI, DI: Updated by number of bytes copied 60 54 ; Corrupts registers: 61 55 ; Nothing 62 56 ;-------------------------------------------------------------------- 63 %ifndef EXCLUDE_FROM_X TIDE_UNIVERSAL_BIOS57 %ifndef EXCLUDE_FROM_XUB 64 58 ALIGN JUMP_ALIGN 65 59 Memory_CopyCXbytesFromDSSItoESDI: 66 OPTIMIZE_STRING_OPERATION rep, movs 60 push cx 61 OPTIMIZE_STRING_OPERATION movs 62 pop cx 67 63 ret 68 64 %endif … … 77 73 ; Nothing 78 74 ; Corrupts registers: 79 ; Nothing75 ; CX 80 76 ;-------------------------------------------------------------------- 81 77 %ifdef INCLUDE_MENU_LIBRARY … … 102 98 ; DI: Updated by number of BYTEs stored 103 99 ; Corrupts registers: 104 ; AX 100 ; AX, CX 105 101 ;-------------------------------------------------------------------- 106 102 ALIGN JUMP_ALIGN … … 118 114 ; DI: Updated by number of BYTEs stored 119 115 ; Corrupts registers: 120 ; Nothing116 ; CX 121 117 ;-------------------------------------------------------------------- 122 ALIGN JUMP_ALIGN123 118 Memory_StoreCXbytesFromAccumToESDI: 124 OPTIMIZE_STRING_OPERATION rep,stos119 OPTIMIZE_STRING_OPERATION stos 125 120 ret 126 121 … … 135 130 ; AX 136 131 ;-------------------------------------------------------------------- 137 %ifndef EXCLUDE_FROM_X TIDE_UNIVERSAL_BIOS132 %ifndef EXCLUDE_FROM_XUB 138 133 ALIGN JUMP_ALIGN 139 134 Memory_ReserveCXbytesFromStackToDSSI: -
trunk/Assembly_Library/Src/Util/Reboot.asm
r526 r592 44 44 mov al, 0FEh ; System reset (AT+ keyboard controller) 45 45 out 64h, al ; Reset computer (AT+) 46 %ifndef EXCLUDE_FROM_X TIDE_UNIVERSAL_BIOS46 %ifndef EXCLUDE_FROM_XUB 47 47 %ifdef INCLUDE_TIME_LIBRARY 48 48 mov ax, 10 -
trunk/Assembly_Library/Src/Util/Registers.asm
r526 r592 59 59 %endif 60 60 61 %ifndef EXCLUDE_FROM_X TIDE_UNIVERSAL_BIOS61 %ifndef EXCLUDE_FROM_XUB 62 62 ALIGN JUMP_ALIGN 63 63 Registers_CopySSBPtoDSSI: … … 91 91 ; 92 92 ;-------------------------------------------------------------------- 93 %ifndef EXCLUDE_FROM_X TIDE_UNIVERSAL_BIOSOR EXCLUDE_FROM_XTIDECFG93 %ifndef EXCLUDE_FROM_XUB OR EXCLUDE_FROM_XTIDECFG 94 94 ALIGN JUMP_ALIGN 95 95 Registers_NormalizeESSI: 96 96 mov cx, si 97 and si, byte 0fh98 jmp Registers_NormalizeFinish97 and si, BYTE 0Fh 98 jmp SHORT Registers_NormalizeFinish 99 99 100 100 ALIGN JUMP_ALIGN 101 101 Registers_NormalizeESDI: 102 102 mov cx, di 103 and di, byte 0fh103 and di, BYTE 0Fh 104 104 ;;; fall-through 105 105 -
trunk/Assembly_Library/Src/Util/Size.asm
r580 r592 70 70 jae SHORT Size_DivideSizeInBXDXAXby1024andIncrementMagnitudeInCX 71 71 add sp, BYTE 2 ; Clean return address from stack 72 xchg si, cx ; CX = Remainder (0...1023), SI = Magnitude73 72 74 73 ; Convert remainder to tenths 75 xchg bx, ax ; Store AX 76 mov al, 5 ; AH = 0 77 mul cx ; DX:AX = remainder * (10 / 2) 78 %ifdef USE_186 79 shr ax, 9 ; Divide AX by (1024 / 2) 80 %else 81 shr ax, 1 82 mov al, ah 83 cbw 84 %endif 85 xchg cx, ax ; CX = tenths 86 xchg ax, bx 74 mov bx, 640 75 xchg bx, ax ; BX = Size, AX = (10 / 1024) * 65536 76 mul si ; DX = Remainder * (10 / 1024) 77 xchg dx, ax 78 xchg cx, ax ; CX = Tenths, AX = Magnitude 79 xchg bx, ax ; AX = Size, BX = Magnitude 87 80 88 81 ; Convert magnitude to character 89 mov dl, [cs: si+.rgbMagnitudeToChar]82 mov dl, [cs:bx+.rgbMagnitudeToChar] 90 83 91 84 pop si … … 154 147 ; Nothing 155 148 ;-------------------------------------------------------------------- 156 %ifdef EXCLUDE_FROM_X TIDE_UNIVERSAL_BIOS149 %ifdef EXCLUDE_FROM_XUB 157 150 %ifdef USE_386 158 151 %define EXCLUDE -
trunk/Assembly_Library/Src/Util/Sort.asm
r526 r592 63 63 push cx 64 64 65 %ifdef CLD_NEEDED 65 66 cld 67 %endif 66 68 mov cx, di ; Restore item size to CX 67 69 xor ax, ax ; Zero starting index … … 191 193 192 194 cmp ax, dx ; If (left <= right) 193 jg SHORT ArrangeItemsInRangeAXtoDXtoBothSidesOfPivotInESDI195 jg SHORT .BreakLoopSinceAllItemsExamined 194 196 call SwapItemsFromIndexesAXandDX 195 197 inc ax
Note:
See TracChangeset
for help on using the changeset viewer.