- NAME
- #include <proto/utility.h>
ULONG UMult32 (arg1 , arg2)
- LOCATION
- In UtilityBase at offset 24
- SYNOPSIS
- ULONG arg1
ULONG arg2
- FUNCTION
- Performs an unsigned 32-bit multiplication of arg1 * arg2 and returns a 32 bit value.
- INPUTS
arg1, arg2 - 32 bit unsigned longs
- RESULT
- arg1 * arg2
- EXAMPLE
LONG a = 352543;
LONG b = 52464;
LONG c = UMult32(a,b);
c == 1315946768
- SEE ALSO
- utility/ SMult32(), utility/ UMult64(), utility/ SMult64()
- NOTES
- This can perform the multiplication either using the machines native instructions (if they exist), or in software using a simple algorithm (three multiplications, two shifts and an addition.
The utility.library math functions are unlike all other utility functions in that they don't require the library base to be loaded in register A6, and they also save the values of the address registers A0/A1.
This function is mainly to support assembly programers, and is probably of limited use to higher-level language programmers.
- BUGS
- INTERNALS
- May be handled by code in config/$(KERNEL), may not be...
It is for m68k-native...
To emulate this operation we are performing the operation:
(2^16 * a + b) * (2^16 * c + d) = 2^32 * ab + 2^16 * ad + 2^16 * bc + bd = 2^32 * ab + 2^16 ( ad + bc ) + bd
Now since the result is a 32-bit number, the 2^32 term will have no effect. (Since 2^32 > max (32-bit number).
Therefore: product = 2^16( ad + bc ) + bd
- HISTORY
- 20.10.1998 hkiel
-
Amiga Research OS
- 20.08.1997 digulla
-
Polish.
Renamed utility_intern.h to intern.h.
- 03.02.1997 ldp
-
Changed <proto/*_protos.h> to <proto/*.h>
- 02.02.1997 iaint
-
Some bug fixes, math functions and native Amiga support
- 27.01.1997 ldp
-
Polish
- 10.12.1996 aros
-
Moved #include into first column to allow makedepend to see it.
- 24.10.1996 aros
-
Use proper Amiga datatypes (eg: ULONG not unsigned long)
- 24.10.1996 aros
-
Use the official AROS macros over the __AROS versions.
- 31.08.1996 aros
-
Merged in/modified for FreeBSD.