摘要 |
A method and apparatus to perform efficient software-based integer division. The equivalent of a hardware-based integer division operation is enabled via a reciprocal multiplication operation that is facilitated by a minimum combination of multiplication (and/or add) and shift operations. Properties and equations are derived for determining minimum multiplication and shift instructions to perform an integer division of a variable dividend and constant divisor using reciprocal multiplication. Computer functions are disclosed for determining parameters from which the minimum multiplication and shift instructions can be derived. Software/firmware is then coded employing the minimum multiplication and shift instructions to perform software-based integer division operations via reciprocal multiplication. In one embodiment, the integer division operations are employed to determine a minimum number of cells required to store the data in a packet or frame that is processed by a network processor.
|