format MS COFF
public _ULongToFloat ; ascall
public _LongShiftLeft ; ascall + cl
public _LongShiftRight ; ascall + cl
public _ULongShiftRight ; ascall + cl
public _LongMul ; ascall
section ".code" code readable executable
;------------------------------------------------
_LongShiftRight:
cmp cl, 64
jae _LongShiftRight_1
cmp cl, 32
jbe _LongShiftRight_2
and cl, 31
mov eax, edx
sar edx, 31
sar eax, cl
ret
_LongShiftRight_2:
shrd eax, edx, cl
sar edx, cl
ret
_LongShiftRight_1:
sar edx, 31
mov eax, edx
ret
;------------------------------------------------
_ULongShiftRight:
cmp cl, 64
jae _ULongShiftRight_1
cmp cl, 32
jbe _ULongShiftRight_2
and cl, 31
mov eax, edx
xor edx, edx
shr eax, cl
ret
_ULongShiftRight_2:
shrd eax, edx, cl
shr edx, cl
ret
_ULongShiftRight_1:
xor edx, edx
xor eax, eax
ret
;------------------------------------------------
_LongShiftLeft:
cmp cl, 64
jae _LongShiftLeft_1
cmp cl, 32
jbe _LongShiftLeft_2
and cl, 31
mov edx, eax
xor eax, eax
shl edx, cl
ret
_LongShiftLeft_2:
shld edx, eax, cl
shl eax, cl
ret
_LongShiftLeft_1:
xor edx, edx
xor eax, eax
ret
;------------------------------------------------
_ULongToFloat:
mov eax, dword[esp + 8]
and dword[esp + 8], 0x7FFFFFFF
fild qword[esp + 4]
and eax, 0x80000000
mov dword[esp + 4], 0
mov dword[esp + 8], eax
fild qword[esp + 4]
fchs
faddp
ret 8
;------------------------------------------------
_LongMul:
mov eax, dword[esp + 4]
mov edx, dword[esp + 8]
push dword[esp + 12]
push dword[esp + 16]
call _LongMul_AsCall
ret 16
_LongMul_AsCall:
mov ecx, edx
or ecx, dword[esp + 8]
jnz _LongMul_1
mul dword[esp + 4]
ret 8
_LongMul_1:
mov dword[esp - 4], edx
mul dword[esp + 4]
mov dword[esp - 8], eax
mov ecx, edx
mov eax, dword[esp - 4]
mul dword[esp + 8]
mov edx, eax
add edx, ecx
mov eax, dword[esp - 8]
ret 8