Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MUI_ALIGN
- ;------------------------------------------------------------------------------
- ; _HV_FastDivide - Divide an unsigned number by a divisor.
- ; Division without div instruction for common divisor numbers
- ; https://godbolt.org/z/sKWfdqYPP
- ;------------------------------------------------------------------------------
- _HV_FastDivide PROC USES ECX EDX dwNumber:DWORD, dwDivisor:DWORD
- .IF dwNumber == 0
- mov eax, 0
- ret
- .ENDIF
- mov eax, dwDivisor
- .IF eax == 0
- mov eax, 0
- ret
- .ELSEIF eax == 1
- mov eax, dwNumber
- ret
- .ELSEIF eax == 2
- mov eax, dwNumber
- shr eax, 1
- .ELSEIF eax == 3
- mov eax, dwNumber
- mov edx, -1431655765
- mul edx
- mov eax, edx
- shr eax, 1
- .ELSEIF eax == 4
- mov eax, dwNumber
- shr eax, 2
- .ELSEIF eax == 5
- mov eax, dwNumber
- mov edx, -858993459
- mul edx
- mov eax, edx
- shr eax, 2
- .ELSEIF eax == 6
- mov eax, dwNumber
- mov edx, -1431655765
- mul edx
- mov eax, edx
- shr eax, 2
- .ELSEIF eax == 7
- mov eax, dwNumber
- mov edx, 613566757
- mov ecx, eax
- mul edx
- mov eax, ecx
- sub eax, edx
- shr eax, 1
- add eax, edx
- shr eax, 2
- .ELSEIF eax == 8
- mov eax, dwNumber
- shr eax, 3
- .ELSEIF eax == 9
- mov eax, dwNumber
- mov edx, 954437177
- mul edx
- mov eax, edx
- shr eax, 1
- .ELSEIF eax == 10
- mov eax, dwNumber
- mov edx, -858993459
- mul edx
- mov eax, edx
- shr eax, 3
- .ELSEIF eax == 11
- mov eax, dwNumber
- mov edx, -1171354717
- mul edx
- mov eax, edx
- shr eax, 3
- .ELSEIF eax == 12
- mov eax, dwNumber
- mov edx, -1431655765
- mul edx
- mov eax, edx
- shr eax, 3
- .ELSEIF eax == 13
- mov eax, dwNumber
- mov edx, 1321528399
- mul edx
- mov eax, edx
- shr eax, 2
- .ELSEIF eax == 14
- mov eax, dwNumber
- shr eax, 1
- mov edx, -1840700269
- mul edx
- mov eax, edx
- shr eax, 2
- .ELSEIF eax == 15
- mov eax, dwNumber
- mov edx, -2004318071
- mul edx
- mov eax, edx
- shr eax, 3
- .ELSEIF eax == 16
- mov eax, dwNumber
- shr eax, 4
- .ELSEIF eax == 20
- mov eax, dwNumber
- mov edx, -858993459
- mul edx
- mov eax, edx
- shr eax, 4
- .ELSEIF eax == 24
- mov eax, dwNumber
- mov edx, -1431655765
- mul edx
- mov eax, edx
- shr eax, 4
- .ELSEIF eax == 25
- mov eax, dwNumber
- mov edx, 1374389535
- mul edx
- mov eax, edx
- shr eax, 3
- .ELSEIF eax == 28
- mov eax, dwNumber
- shr eax, 2
- mov edx, 613566757
- mul edx
- mov eax, edx
- .ELSEIF eax == 30
- mov eax, dwNumber
- mov edx, -2004318071
- mul edx
- mov eax, edx
- shr eax, 4
- .ELSEIF eax == 32
- mov eax, dwNumber
- shr eax, 5
- .ELSEIF eax == 36
- mov eax, dwNumber
- mov edx, 954437177
- mul edx
- mov eax, edx
- shr eax, 3
- .ELSEIF eax == 40
- mov eax, dwNumber
- mov edx, -858993459
- mul edx
- mov eax, edx
- shr eax, 5
- .ELSEIF eax == 44
- mov eax, dwNumber
- mov edx, -1171354717
- mul edx
- mov eax, edx
- shr eax, 5
- .ELSEIF eax == 45
- mov eax, dwNumber
- mov edx, 1813430637
- mov ecx, eax
- mul edx
- mov eax, ecx
- sub eax, edx
- shr eax, 1
- add eax, edx
- shr eax, 5
- .ELSEIF eax == 48
- mov eax, dwNumber
- mov edx, -1431655765
- mul edx
- mov eax, edx
- shr eax, 5
- .ELSEIF eax == 50
- mov eax, dwNumber
- mov edx, 1374389535
- mul edx
- mov eax, edx
- shr eax, 4
- .ELSEIF eax == 52
- mov eax, dwNumber
- mov edx, 1321528399
- mul edx
- mov eax, edx
- shr eax, 4
- .ELSEIF eax == 56
- mov eax, dwNumber
- shr eax, 3
- mov edx, 613566757
- mul edx
- mov eax, edx
- .ELSEIF eax == 60
- mov eax, dwNumber
- mov edx, -2004318071
- mul edx
- mov eax, edx
- shr eax, 5
- .ELSEIF eax == 64
- mov eax, dwNumber
- shr eax, 6
- .ELSEIF eax == 68
- mov eax, dwNumber
- mov edx, -252645135
- mul edx
- mov eax, edx
- shr eax, 6
- .ELSEIF eax == 72
- mov eax, dwNumber
- mov edx, 954437177
- mul edx
- mov eax, edx
- shr eax, 4
- .ELSEIF eax == 75
- mov eax, dwNumber
- mov edx, 458129845
- mul edx
- mov eax, edx
- shr eax, 3
- .ELSEIF eax == 76
- mov eax, dwNumber
- shr eax, 2
- mov edx, 452101821
- mul edx
- mov eax, edx
- shr eax, 1
- .ELSEIF eax == 80
- mov eax, dwNumber
- mov edx, -858993459
- mul edx
- mov eax, edx
- shr eax, 6
- .ELSEIF eax == 84
- mov eax, dwNumber
- shr eax, 2
- mov edx, 818089009
- mul edx
- mov eax, edx
- shr eax, 2
- .ELSEIF eax == 88
- mov eax, dwNumber
- mov edx, -1171354717
- mul edx
- mov eax, edx
- shr eax, 6
- .ELSEIF eax == 90
- mov eax, dwNumber
- shr eax, 1
- mov edx, -1240768329
- mul edx
- mov eax, edx
- shr eax, 5
- .ELSEIF eax == 92
- mov eax, dwNumber
- mov edx, -1307163959
- mul edx
- mov eax, edx
- shr eax, 6
- .ELSEIF eax == 96
- mov eax, dwNumber
- mov edx, -1431655765
- mul edx
- mov eax, edx
- shr eax, 6
- .ELSEIF eax == 100
- mov eax, dwNumber
- mov edx, 1374389535
- mul edx
- mov eax, edx
- shr eax, 5
- .ELSEIF eax == 112
- mov eax, dwNumber
- shr eax, 4
- mov edx, 613566758
- mul edx
- mov eax, edx
- .ELSEIF eax == 120
- mov eax, dwNumber
- mov edx, -2004318071
- mul edx
- mov eax, edx
- shr eax, 6
- .ELSEIF eax == 125
- mov eax, dwNumber
- mov edx, 274877907
- mul edx
- mov eax, edx
- shr eax, 3
- .ELSEIF eax == 128
- mov eax, dwNumber
- shr eax, 7
- .ELSEIF eax == 135
- mov eax, dwNumber
- mov edx, -222702007
- mul edx
- mov eax, edx
- shr eax, 7
- .ELSEIF eax == 144
- mov eax, dwNumber
- mov edx, 954437177
- mul edx
- mov eax, edx
- shr eax, 5
- .ELSEIF eax == 150
- mov eax, dwNumber
- mov edx, 458129845
- mul edx
- mov eax, edx
- shr eax, 4
- .ELSEIF eax == 160
- mov eax, dwNumber
- mov edx, -858993459
- mul edx
- mov eax, edx
- shr eax, 7
- .ELSEIF eax == 165
- mov eax, dwNumber
- mov edx, 1665926709
- mul edx
- mov eax, edx
- shr eax, 6
- .ELSEIF eax == 176
- mov eax, dwNumber
- mov edx, -1171354717
- mul edx
- mov eax, edx
- shr eax, 7
- .ELSEIF eax == 180
- mov eax, dwNumber
- shr eax, 2
- mov edx, 381774871
- mul edx
- mov eax, edx
- shr eax, 2
- .ELSEIF eax == 192
- mov eax, dwNumber
- mov edx, -1431655765
- mul edx
- mov eax, edx
- shr eax, 7
- .ELSEIF eax == 200
- mov eax, dwNumber
- mov edx, 1374389535
- mul edx
- mov eax, edx
- shr eax, 6
- .ELSEIF eax == 225
- mov eax, dwNumber
- mov edx, -1851608123
- mul edx
- mov eax, edx
- shr eax, 7
- .ELSEIF eax == 250
- mov eax, dwNumber
- mov edx, 274877907
- mul edx
- mov eax, edx
- shr eax, 4
- .ELSEIF eax == 256
- mov eax, dwNumber
- shr eax, 8
- .ELSEIF eax == 270
- mov eax, dwNumber
- mov edx, -222702007
- mul edx
- mov eax, edx
- shr eax, 8
- .ELSEIF eax == 300
- mov eax, dwNumber
- mov edx, 458129845
- mul edx
- mov eax, edx
- shr eax, 5
- .ELSEIF eax == 315
- mov eax, dwNumber
- mov edx, -1608908383
- mov ecx, eax
- mul edx
- mov eax, ecx
- sub eax, edx
- shr eax, 1
- add eax, edx
- shr eax, 8
- .ELSEIF eax == 360
- mov eax, dwNumber
- shr eax, 3
- mov edx, 381774871
- mul edx
- mov eax, edx
- shr eax, 2
- .ELSEIF eax == 480
- mov eax, dwNumber
- mov edx, -2004318071
- mul edx
- mov eax, edx
- shr eax, 8
- .ELSEIF eax == 500
- mov eax, dwNumber
- mov edx, 274877907
- mul edx
- mov eax, edx
- shr eax, 5
- .ELSEIF eax == 512
- mov eax, dwNumber
- shr eax, 9
- .ELSEIF eax == 640
- mov eax, dwNumber
- mov edx, -858993459
- mul edx
- mov eax, edx
- shr eax, 9
- .ELSEIF eax == 1000
- mov eax, dwNumber
- mov edx, 274877907
- mul edx
- mov eax, edx
- shr eax, 6
- .ELSEIF eax == 1024
- mov eax, dwNumber
- shr eax, 10
- .ELSEIF eax == 1080
- mov eax, dwNumber
- mov edx, -222702007
- mul edx
- mov eax, edx
- shr eax, 10
- .ELSEIF eax == 1440
- mov eax, dwNumber
- shr eax, 5
- mov edx, 95443718
- mul edx
- mov eax, edx
- .ELSEIF eax == 1920
- mov eax, dwNumber
- mov edx, -2004318071
- mul edx
- mov eax, edx
- shr eax, 10
- .ELSEIF eax == 2000
- mov eax, dwNumber
- mov edx, 274877907
- mul edx
- mov eax, edx
- shr eax, 7
- .ELSEIF eax == 2048
- mov eax, dwNumber
- shr eax, 11
- .ELSEIF eax == 2560
- mov eax, dwNumber
- mov edx, -858993459
- mul edx
- mov eax, edx
- shr eax, 11
- .ELSEIF eax == 4096
- mov eax, dwNumber
- shr eax, 12
- .ELSEIF eax == 5000
- mov eax, dwNumber
- mov edx, -776530087
- mul edx
- mov eax, edx
- shr eax, 12
- .ELSEIF eax == 8192
- mov eax, dwNumber
- shr eax, 13
- .ELSEIF eax == 10000
- mov eax, dwNumber
- mov edx, -776530087
- mul edx
- mov eax, edx
- shr eax, 13
- .ELSEIF eax == 16384
- mov eax, dwNumber
- shr eax, 14
- .ELSEIF eax == 32768
- mov eax, dwNumber
- shr eax, 15
- .ELSEIF eax == 65536
- mov eax, dwNumber
- shr eax, 16
- .ELSEIF eax == 131072
- mov eax, dwNumber
- shr eax, 17
- .ELSEIF eax == 262144
- mov eax, dwNumber
- shr eax, 18
- .ELSEIF eax == 524288
- mov eax, dwNumber
- shr eax, 19
- .ELSEIF eax == 1048576
- mov eax, dwNumber
- shr eax, 20
- .ELSE
- mov eax, dwNumber
- mov ecx, dwDivisor
- xor edx, edx
- .IF eax != 0 && ecx != 0
- div ecx
- .ELSE
- mov eax, 0
- .ENDIF
- ; result in eax
- .ENDIF
- ret
- _HV_FastDivide ENDP
- MUI_ALIGN
- ;------------------------------------------------------------------------------
- ; _HV_MODX - Calc the modulus of an unsigned number
- ; Remainder of division without div instruction for common mod numbers
- ; https://godbolt.org/z/sKWfdqYPP
- ;------------------------------------------------------------------------------
- _HV_MODX PROC USES ECX EDX dwNumber:DWORD, dwMod:DWORD
- .IF dwNumber == 0
- mov eax, 0
- ret
- .ENDIF
- mov eax, dwMod
- .IF eax == 0 || eax == 1
- mov eax, 0
- ret
- .ELSEIF eax == 2
- mov eax, dwNumber
- and eax, 1
- .ELSEIF eax == 3
- mov eax, dwNumber
- mov edx, -1431655765
- mov ecx, eax
- mul edx
- mov eax, edx
- and edx, -2
- shr eax, 1
- add edx, eax
- mov eax, ecx
- sub eax, edx
- .ELSEIF eax == 4
- mov eax, dwNumber
- and eax, 3
- .ELSEIF eax == 5
- mov eax, dwNumber
- mov edx, -858993459
- mov ecx, eax
- mul edx
- mov eax, edx
- and edx, -4
- shr eax, 2
- add edx, eax
- mov eax, ecx
- sub eax, edx
- .ELSEIF eax == 6
- mov eax, dwNumber
- mov edx, -1431655765
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 2
- lea eax, [eax+eax*2]
- add eax, eax
- sub ecx, dwNumber
- mov eax, ecx
- .ELSEIF eax == 7
- mov eax, dwNumber
- mov edx, 613566757
- mov ecx, eax
- mul edx
- mov eax, ecx
- sub eax, edx
- shr eax, 1
- add eax, edx
- shr eax, 2
- lea edx, [0+eax*8]
- sub edx, eax
- mov eax, ecx
- sub eax, edx
- .ELSEIF eax == 8
- mov eax, dwNumber
- and eax, 7
- .ELSEIF eax == 9
- mov eax, dwNumber
- mov edx, 954437177
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 1
- lea eax, [eax+eax*8]
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 10
- mov eax, dwNumber
- mov edx, -858993459
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 3
- lea eax, [eax+eax*4]
- add eax, eax
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 11
- mov eax, dwNumber
- mov edx, -1171354717
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 3
- lea edx, [eax+eax*4]
- lea eax, [eax+edx*2]
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 12
- mov eax, dwNumber
- mov edx, -1431655765
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 3
- lea eax, [eax+eax*2]
- sal eax, 2
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 13
- mov eax, dwNumber
- mov edx, 1321528399
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 2
- lea edx, [eax+eax*2]
- lea eax, [eax+edx*4]
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 14
- mov eax, dwNumber
- mov ecx, eax
- mov edx, -1840700269
- shr eax, 1
- mul edx
- mov eax, edx
- shr eax, 2
- imul eax, eax, 14
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 15
- mov eax, dwNumber
- mov edx, -2004318071
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 3
- mov edx, eax
- sal edx, 4
- sub edx, eax
- mov eax, ecx
- sub eax, edx
- .ELSEIF eax == 16
- mov eax, dwNumber
- and eax, 15
- .ELSEIF eax == 20
- mov eax, dwNumber
- mov edx, -858993459
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 4
- lea eax, [eax+eax*4]
- sal eax, 2
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 24
- mov eax, dwNumber
- mov edx, -1431655765
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 4
- lea eax, [eax+eax*2]
- sal eax, 3
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 25
- mov eax, dwNumber
- mov edx, 1374389535
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 3
- lea eax, [eax+eax*4]
- lea eax, [eax+eax*4]
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 28
- mov eax, dwNumber
- mov edx, eax
- push ebx
- mov ecx, eax
- mov ebx, 613566757
- shr edx, 2
- mov eax, edx
- mul ebx
- mov eax, ecx
- pop ebx
- imul edx, edx, 28
- sub eax, edx
- .ELSEIF eax == 30
- mov eax, dwNumber
- mov edx, -2004318071
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 4
- imul eax, eax, 30
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 32
- mov eax, dwNumber
- and eax, 31
- .ELSEIF eax == 36
- mov eax, dwNumber
- mov edx, 954437177
- mov ecx, eax
- mul edx
- mov eax, edx
- and edx, 1073741816
- shr eax, 3
- add edx, eax
- mov eax, ecx
- sal edx, 2
- sub eax, edx
- .ELSEIF eax == 40
- mov eax, dwNumber
- mov edx, -858993459
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 5
- lea eax, [eax+eax*4]
- sal eax, 3
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 44
- mov eax, dwNumber
- mov edx, -1171354717
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 5
- imul eax, eax, 44
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 45
- mov eax, dwNumber
- mov edx, 1813430637
- mov ecx, eax
- mul edx
- mov eax, ecx
- sub eax, edx
- shr eax, 1
- add eax, edx
- shr eax, 5
- imul eax, eax, 45
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 48
- mov eax, dwNumber
- mov edx, -1431655765
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 5
- lea eax, [eax+eax*2]
- sal eax, 4
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 50
- mov eax, dwNumber
- mov edx, 1374389535
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 4
- imul eax, eax, 50
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 52
- mov eax, dwNumber
- mov edx, 1321528399
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 4
- imul eax, eax, 52
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 56
- mov eax, dwNumber
- mov edx, eax
- push ebx
- mov ecx, eax
- mov ebx, 613566757
- shr edx, 3
- mov eax, edx
- mul ebx
- mov eax, ecx
- pop ebx
- imul edx, edx, 56
- sub eax, edx
- .ELSEIF eax == 60
- mov eax, dwNumber
- mov edx, -2004318071
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 5
- imul eax, eax, 60
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 64
- mov eax, dwNumber
- and eax, 63
- .ELSEIF eax == 68
- mov eax, dwNumber
- mov edx, -252645135
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 6
- imul eax, eax, 68
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 72
- mov eax, dwNumber
- mov edx, 954437177
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 4
- lea eax, [eax+eax*8]
- sal eax, 3
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 75
- mov eax, dwNumber
- mov edx, 458129845
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 3
- imul eax, eax, 75
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 76
- mov eax, dwNumber
- mov ecx, eax
- mov edx, 452101821
- shr eax, 2
- mul edx
- mov eax, edx
- shr eax, 1
- imul eax, eax, 76
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 80
- mov eax, dwNumber
- mov edx, -858993459
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 6
- lea eax, [eax+eax*4]
- sal eax, 4
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 84
- mov eax, dwNumber
- mov ecx, eax
- mov edx, 818089009
- shr eax, 2
- mul edx
- mov eax, edx
- shr eax, 2
- imul eax, eax, 84
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 88
- mov eax, dwNumber
- mov edx, -1171354717
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 6
- imul eax, eax, 88
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 90
- mov eax, dwNumber
- mov ecx, eax
- mov edx, -1240768329
- shr eax, 1
- mul edx
- mov eax, edx
- shr eax, 5
- imul eax, eax, 90
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 92
- mov eax, dwNumber
- mov edx, -1307163959
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 6
- imul eax, eax, 92
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 96
- mov eax, dwNumber
- mov edx, -1431655765
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 6
- lea eax, [eax+eax*2]
- sal eax, 5
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 100
- mov eax, dwNumber
- mov edx, 1374389535
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 5
- imul eax, eax, 100
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 120
- mov eax, dwNumber
- mov edx, -2004318071
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 6
- imul eax, eax, 120
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 125
- mov eax, dwNumber
- mov edx, 274877907
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 3
- imul eax, eax, 125
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 128
- mov eax, dwNumber
- and eax, 127
- .ELSEIF eax == 135
- mov eax, dwNumber
- mov edx, -222702007
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 7
- imul eax, eax, 135
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 144
- mov eax, dwNumber
- mov edx, 954437177
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 5
- lea eax, [eax+eax*8]
- sal eax, 4
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 150
- mov eax, dwNumber
- mov edx, 458129845
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 4
- imul eax, eax, 150
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 175
- mov eax, dwNumber
- mov edx, 1570730897
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 6
- imul eax, eax, 175
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 180
- mov eax, dwNumber
- mov ecx, eax
- mov edx, 381774871
- shr eax, 2
- mul edx
- mov eax, edx
- shr eax, 2
- imul eax, eax, 180
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 192
- mov eax, dwNumber
- mov edx, -1431655765
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 7
- lea eax, [eax+eax*2]
- sal eax, 6
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 200
- mov eax, dwNumber
- mov edx, 1374389535
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 6
- imul eax, eax, 200
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 225
- mov eax, dwNumber
- mov edx, -1851608123
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 7
- imul eax, eax, 225
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 256
- mov eax, dwNumber
- movzx eax, al
- .ELSEIF eax == 270
- mov eax, dwNumber
- mov edx, -222702007
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 8
- imul eax, eax, 270
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 300
- mov eax, dwNumber
- mov edx, 458129845
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 5
- imul eax, eax, 300
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 315
- mov eax, dwNumber
- mov edx, -1608908383
- mov ecx, eax
- mul edx
- mov eax, ecx
- sub eax, edx
- shr eax, 1
- add eax, edx
- shr eax, 8
- imul eax, eax, 315
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 360
- mov eax, dwNumber
- mov ecx, eax
- mov edx, 381774871
- shr eax, 3
- mul edx
- mov eax, edx
- shr eax, 2
- imul eax, eax, 360
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 480
- mov eax, dwNumber
- mov edx, -2004318071
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 8
- imul eax, eax, 480
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 512
- mov eax, dwNumber
- and eax, 511
- .ELSEIF eax == 768
- mov eax, dwNumber
- mov edx, -1431655765
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 9
- lea eax, [eax+eax*2]
- sal eax, 8
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 1000
- mov eax, dwNumber
- mov edx, 274877907
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 6
- imul eax, eax, 1000
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 1024
- mov eax, dwNumber
- and eax, 1023
- .ELSEIF eax == 1080
- mov eax, dwNumber
- mov edx, -222702007
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 10
- imul eax, eax, 1080
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 1440
- mov eax, dwNumber
- mov edx, eax
- push ebx
- mov ecx, eax
- mov ebx, 95443718
- shr edx, 5
- mov eax, edx
- mul ebx
- mov eax, ecx
- pop ebx
- imul edx, edx, 1440
- sub eax, edx
- .ELSEIF eax == 1920
- mov eax, dwNumber
- mov edx, -2004318071
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 10
- imul eax, eax, 1920
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 2000
- mov eax, dwNumber
- mov edx, 274877907
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 7
- imul eax, eax, 2000
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 2048
- mov eax, dwNumber
- and eax, 2047
- .ELSEIF eax == 2560
- mov eax, dwNumber
- mov edx, -858993459
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 11
- lea eax, [eax+eax*4]
- sal eax, 9
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 4096
- mov eax, dwNumber
- and eax, 4095
- .ELSEIF eax == 8192
- mov eax, dwNumber
- and eax, 8191
- .ELSEIF eax == 10000
- mov eax, dwNumber
- mov edx, -776530087
- mov ecx, eax
- mul edx
- mov eax, edx
- shr eax, 13
- imul eax, eax, 10000
- sub ecx, eax
- mov eax, ecx
- .ELSEIF eax == 16384
- mov eax, dwNumber
- and eax, 16383
- .ELSEIF eax == 32768
- mov eax, dwNumber
- and eax, 32767
- .ELSEIF eax == 65536
- mov eax, dwNumber
- movzx eax, ax
- .ELSEIF eax == 131072
- mov eax, dwNumber
- and eax, 131071
- .ELSEIF eax == 262144
- mov eax, dwNumber
- and eax, 262143
- .ELSEIF eax == 524288
- mov eax, dwNumber
- and eax, 524287
- .ELSEIF eax == 1048576
- mov eax, dwNumber
- and eax, 1048575
- .ELSE
- mov eax, dwNumber
- mov ecx, dwMod
- xor edx, edx
- div ecx
- mov eax, edx
- .ENDIF
- ret
- _HV_MODX ENDP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement