[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] DIV instruction (WAS: Global variables and ISRs ???)

From: Vincent Trouilliez
Subject: Re: [avr-gcc-list] DIV instruction (WAS: Global variables and ISRs ???)
Date: Wed, 07 Sep 2005 14:06:03 +0200

> Hardware division requires far more chip area than hardware multiplication,
> and division is very seldom used compared to multiplication.  So almost no
> small microcontroller has one these days - you have look at high-end 32-bit
> chips to get hardware division, and even then it is significantly slower
> than multiplication.  Chips like the 8051 have microcoded division - you'll
> find it takes lots of clock cycles.

Only 4 machine-cycles accoridng to the documentation...
But... I looked at an 8051 assembler routine that divide  a 32bit by a
16 bit, and not even did it use the 'DIV' instruction... it only
involved logical operations or basic sub/add instructions, which the AVR
can do very fast :-)  

> If you can stick to division by constants,

Well sure, I obviously steer clear away from floating point
calculations ! I figure it's still better to use very large integer
numbers to increase the accuracy as needed, then just placing the
decimal point where required, than resorting to FP routines...
Integer number crunching is fast :-)

> gcc will generate good code by multiplying by the reciprical.

Sounds like the H/W multiplier was all that was really needed in
practice then, good :o)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]