2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
5 Desc: Unsigned 64-bit product of two 32-bit numbers.
10 /*****************************************************************************
13 #include <proto/utility.h>
15 AROS_LH2(UQUAD
, UMult64
,
18 AROS_LHA(ULONG
, arg1
, D0
),
19 AROS_LHA(ULONG
, arg2
, D1
),
22 struct UtilityBase
*, UtilityBase
, 34, Utility
)
25 Compute the unsigned 64-bit product of arg1 * arg2.
28 arg1, arg2 - 32 bit unsigned numbers.
34 For m68k assembly programmers, UQUADs are returned in D0:D1 (with
35 the high 32 bits in D0.
37 This function is really only for people programming in
38 assembly on real Amigas. Most compilers will be able to do this
46 SMult32(), UMult32(), SMult64()
49 This may or may not be handled by code in config/$(KERNEL),
50 for m68k-native it is...
52 This is essentially UMult32(), but with the code to calculate
53 the product of the high 32 bits of the multiplicands.
56 29-10-95 digulla automatically created from
57 utility_lib.fd and clib/utility_protos.h
58 18-08-96 iaint Modified UMult32().
60 *****************************************************************************/
64 /* If we have native support for 32 * 32 -> 64, use that. */
65 return (UQUAD
)arg1
* arg2
;
69 /* This is partially the algoritm that is used, however for a
70 more complete version see config/m68k-native/smult64.s
72 This version has problems with:
73 - adding the partial products together
74 - setting the value of QUADs
81 a1
= (arg1
>> 16) & 0xffff;
83 b1
= (arg2
>> 16) & 0xffff;
86 part_prod
= (a0
* b1
) + (a1
* b0
);
88 SET_HIGH32OF64(product
, (part_prod
>> 16) + (a1
* b1
));
89 SET_LOW32OF64(product
, ((part_prod
& 0xFFFF) << 16) + (a0
* b0
));