Re: Division algorithm optimisation
From: Jan-Hinnerk Reichert (hinni_at_despammed.com)
Date: 10/23/04
- Next message: Malte Wolters: "How to boot linux kernel and give a root filesystem from flash"
- Previous message: Mike Harding: "Re: Zilog Z8S180 problems - solved"
- In reply to: Jonathan Kirwan: "Re: Division algorithm optimisation"
- Next in thread: Jonathan Kirwan: "Re: Division algorithm optimisation"
- Reply: Jonathan Kirwan: "Re: Division algorithm optimisation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Malte Wolters: "How to boot linux kernel and give a root filesystem from flash"
- Previous message: Mike Harding: "Re: Zilog Z8S180 problems - solved"
- In reply to: Jonathan Kirwan: "Re: Division algorithm optimisation"
- Next in thread: Jonathan Kirwan: "Re: Division algorithm optimisation"
- Reply: Jonathan Kirwan: "Re: Division algorithm optimisation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|