Re: Division algorithm optimisation

From: Jan-Hinnerk Reichert (hinni_at_despammed.com)
Date: 10/23/04


Date: Sat, 23 Oct 2004 10:46:02 +0200

Jonathan Kirwan wrote:

--------------------------------------------------------------------------
> ;
> ; This routine provides division of an unsigned, 32-bit dividend
> by an
> ; unsigned, 16-bit divisor and produces an unsigned, 16-bit
> quotient and
> ; an unsigned, 16-bit remainder. Essentially, this is ( R14:R15 /
> R13 ). ;
> ; No normalization takes place in this routine and no exponent is
> produced. ;
> ; Inputs:
> ;
> ; R13 unsigned 16-bit divisor
> ; R14 unsigned high-order 16 bits of the dividend
> ; R15 low-order 16 bits of the dividend
> ;
> ; Outputs:
> ;
> ; R14 unsigned 16-bit remainder
> ; R15 unsigned 16-bit quotient
> ;
> ; Scratches:
> ;
> ; R12 counter
>
> Div32u16uQR mov #16, R12 ; set up the shift
> counter
> Div32u16uQR_0 rla R15
> rlc R14
> jc Div32u16uQR_1

Hi Jon,

I can't see the reason for this jump. If I'm not mistaken, it is only
taken if the result doesn't fit into 16-bit.

> sub R13, R14
> jc Div32u16uQR_2
> add R13, R14
> dec R12 ; done?
> jnz Div32u16uQR_0 ; no -- continue
> ret ; yes -- return
> Div32u16uQR_1 sub R13, R14
> Div32u16uQR_2 inc R15
> dec R12 ; done?
> jnz Div32u16uQR_0 ; no -- continue
> ret ; yes -- return



Relevant Pages

  • Re: Quantum propagation from a Dirac initial point
    ... >>I take that the second line is outside of the exponent, ... the second term is a normalization factor. ... I realize now we have two meanings of normalization floating around. ... That's a plausible sort of game, ...
    (sci.physics)
  • Re: Floating Point: Binary Shift Subroutine
    ... I am in the process of rewriting subroutines with no source ... || code All's going well, but ran into this routine. ... | One usenet posting claims that this format has 1 sign bit, 8 exponent ... Then the exponent is 84 (hex). ...
    (comp.lang.fortran)
  • Re: How to calculate logarithm of a signal in FPGA?
    ... learned back during the 1970s and from there I developed the log algo. ... binary point over in the exponent so it ends up be an integer. ... after each squaring and multiplying a modular reduction was performed. ... Also for finding the nth roots, you can embed the log routine into the ...
    (comp.dsp)
  • Re: How to calculate logarithm of a signal in FPGA?
    ... learned back during the 1970s and from there I developed the log algo. ... binary point over in the exponent so it ends up be an integer. ... after each squaring and multiplying a modular reduction was performed. ... Also for finding the nth roots, you can embed the log routine into the ...
    (comp.dsp)
  • Re: subnormal floating point numbers
    ... Everything goes well on PPC ... but on some x86 CPU I get a dramatic loss of performance. ... Your "phantom" is b23 which is low order of the exponent and high order of the mantissa. ... If a float has exponent 0 and any mantissa bit 1 it is declared subnormal because it can't be normalized (Normalization consists of moving mantissa bits left while decrementing the exponent. ...
    (comp.lang.c)