Changeset 141 in xtideuniversalbios for trunk/Assembly_Library/Src/Util
- Timestamp:
- Mar 14, 2011, 3:49:50 PM (14 years ago)
- google:author:
- aitotat
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Assembly_Library/Src/Util/Size.asm
r85 r141 43 43 cmp ax, 10000 ; 5 digits needed? 44 44 jae SHORT Size_DivideSizeInBXDXAXby1024andIncrementMagnitudeInCX 45 add sp, BYTE 2 ; Clean return address from stack 46 xchg si, cx ; CX = Remainder (0...1023), SI = Magnitude 45 47 46 add sp, BYTE 2 ; Clean return address from stack 47 call Size_ConvertMagnitudeRemainderInSItoTenths 48 call Size_GetMagnitudeCharacterToDLfromMagnitudeInCX 49 mov cx, si 48 ; Convert remainder to tenths 49 xchg bx, ax ; Store AX 50 mov ax, 10 51 mul cx ; DX:AX = remainder * 10 52 eSHR_IM ax, 10 ; Divide AX by 1024 53 xchg cx, ax ; CX = tenths 54 xchg ax, bx 55 56 ; Convert magnitude to character 57 mov dl, [cs:si+.rgbMagnitudeToChar] 50 58 51 59 pop si 52 60 ret 61 .rgbMagnitudeToChar: db " kMGTP" 62 53 63 54 64 ;-------------------------------------------------------------------- … … 98 108 rcr ax, 1 ; ...kiB 99 109 ret 100 101 102 ;--------------------------------------------------------------------103 ; Size_ConvertMagnitudeRemainderInSItoTenths104 ; Parameters:105 ; SI: Remainder from last magnitude division (0...1023)106 ; Returns:107 ; SI: Tenths108 ; Corrupts registers:109 ; DX110 ;--------------------------------------------------------------------111 ALIGN JUMP_ALIGN112 Size_ConvertMagnitudeRemainderInSItoTenths:113 push ax114 115 mov ax, 10116 mul si ; DX:AX = remainder * 10117 eSHR_IM ax, 10 ; Divide AX by 1024118 xchg si, ax ; SI = tenths119 120 pop ax121 ret122 123 124 ;--------------------------------------------------------------------125 ; Size_GetMagnitudeCharacterToDLfromMagnitudeInCX126 ; Parameters:127 ; CX: Magnitude in BYTE_MULTIPLES128 ; Returns:129 ; DL: Magnitude character130 ; Corrupts registers:131 ; BX132 ;--------------------------------------------------------------------133 ALIGN JUMP_ALIGN134 Size_GetMagnitudeCharacterToDLfromMagnitudeInCX:135 mov bx, cx136 mov dl, [cs:bx+.rgbMagnitudeToChar]137 ret138 ALIGN WORD_ALIGN139 .rgbMagnitudeToChar: db " kMGTP"
Note:
See TracChangeset
for help on using the changeset viewer.