Changeset 88 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HCapacity.asm
- Timestamp:
- Jan 27, 2011, 8:14:13 AM (14 years ago)
- google:author:
- aitotat
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HCapacity.asm
r32 r88 1 ; File name : HCapacity.asm 2 ; Project name : IDE BIOS 3 ; Created date : 16.3.2010 4 ; Last update : 3.8.2010 5 ; Author : Tomi Tilli 1 ; Project name : XTIDE Universal BIOS 6 2 ; Description : Functions for hard disk capacity calculations. 7 3 … … 47 43 xor bx, bx ; Zero BX for 48-bit sector count 48 44 ret 49 50 51 ;--------------------------------------------------------------------52 ; Converts sector count to hard disk size.53 ;54 ; HCapacity_ConvertSectorCountToSize:55 ; Parameters:56 ; BX:DX:AX: Total sector count57 ; Returns:58 ; AX: Size in magnitude59 ; SI: Tenths60 ; CX: Magnitude character:61 ; 'k' = *1024 B = kiB62 ; 'M' = *1024 kiB = MiB63 ; 'G' = *1024 MiB = GiB64 ; 'T' = *1024 GiB = TiB65 ; 'P' = *1024 TiB = PiB66 ; Corrupts registers:67 ; BX, DX68 ;--------------------------------------------------------------------69 ALIGN JUMP_ALIGN70 HCapacity_ConvertSectorCountToSize:71 call HCapacity_ConvertSectorCountToKiB72 mov cx, 1 ; Magnitude is 1 for kiB73 ALIGN JUMP_ALIGN74 .MagnitudeLoop:75 test bx, bx ; Bits 32...47 in use?76 jnz SHORT .ShiftByMagnitude ; If so, jump to shift77 test dx, dx ; Bits 16...31 in use?78 jnz SHORT .ShiftByMagnitude ; If so, jump to shift79 cmp ax, 10000 ; 5 digits needed?80 jb SHORT .ShiftComplete ; If less, all done81 ALIGN JUMP_ALIGN82 .ShiftByMagnitude:83 call HCapacity_ShiftForNextMagnitude84 jmp SHORT .MagnitudeLoop85 ALIGN JUMP_ALIGN86 .ShiftComplete:87 mov bx, cx ; Copy shift count to BX88 mov cl, [cs:bx+.rgbMagnitudeToChar]89 jmp SHORT HCapacity_ConvertSizeRemainderToTenths90 ALIGN WORD_ALIGN91 .rgbMagnitudeToChar: db " kMGTP"92 93 ;--------------------------------------------------------------------94 ; Converts 48-bit sector count to size in kiB.95 ;96 ; HCapacity_ConvertSectorCountToKiB:97 ; Parameters:98 ; BX:DX:AX: Total sector count99 ; Returns:100 ; BX:DX:AX: Total size in kiB101 ; CF: Remainder from division102 ; Corrupts registers:103 ; Nothing104 ;--------------------------------------------------------------------105 ALIGN JUMP_ALIGN106 HCapacity_ConvertSectorCountToKiB:107 HCapacity_DivideSizeByTwo:108 shr bx, 1 ; Divide sector count by 2...109 rcr dx, 1 ; ...to get disk size in...110 rcr ax, 1 ; ...kiB111 ret112 113 ;--------------------------------------------------------------------114 ; Divides size by 1024 and increments magnitude.115 ;116 ; HCapacity_ShiftForNextMagnitude:117 ; Parameters:118 ; BX:DX:AX: Size in magnitude119 ; CX: Magnitude (0=B, 1=kiB, 2=MiB...)120 ; Returns:121 ; BX:DX:AX: Size in magnitude122 ; SI: Remainder (0...1023)123 ; CX: Magnitude (1=kiB, 2=MiB...)124 ; Corrupts registers:125 ; Nothing126 ;--------------------------------------------------------------------127 ALIGN JUMP_ALIGN128 HCapacity_ShiftForNextMagnitude:129 push cx130 xor si, si ; Zero remainder131 mov cl, 10 ; Divide by 1024132 ALIGN JUMP_ALIGN133 .ShiftLoop:134 call HCapacity_DivideSizeByTwo135 rcr si, 1 ; Update remainder136 loop .ShiftLoop137 eSHR_IM si, 6 ; Remainder to SI beginning138 pop cx139 inc cx ; Increment shift count140 ret141 142 ;--------------------------------------------------------------------143 ; Converts remainder from HCapacity_ShiftForNextMagnitude to tenths.144 ;145 ; HCapacity_ConvertSizeRemainderToTenths:146 ; Parameters:147 ; BX:DX:AX: Size in magnitude148 ; SI: Remainder from last magnitude division (0...1023)149 ; Returns:150 ; BX:DX:AX: Size in magnitude151 ; SI: Tenths152 ; Corrupts registers:153 ; Nothing154 ;--------------------------------------------------------------------155 ALIGN JUMP_ALIGN156 HCapacity_ConvertSizeRemainderToTenths:157 push dx158 push ax159 160 mov ax, 10161 mul si ; DX:AX = remainder * 10162 eSHR_IM ax, 10 ; Divide AX by 1024163 xchg si, ax ; SI = tenths164 165 pop ax166 pop dx167 ret
Note:
See TracChangeset
for help on using the changeset viewer.