avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Global variables and ISRs ???


From: David Brown
Subject: Re: [avr-gcc-list] Global variables and ISRs ???
Date: Wed, 7 Sep 2005 13:03:43 +0200

>
> Talking of instruction, I just noticed that there is a MUL instruction
> in my ATmega32 but no DIV instruction ! How is that even possible...
> even age old 8051 has a division instruction... so we can do quick
> multiplications with the AVR, but need 50 times more cycles to do a
> division ?? I hope I am missing something, because I am finding it very
> inconsistent, and extremely disappointing from this otherwise super
> modern and performant MCU...
> In the long term, I was toying with the idea of playing a bit with fuzzy
> logic and 'Z' filters in control applications, but I guess that will
> require intensive maths, so if I can't even do divisions in hardware...
> I better forget it I guess... until Atmel makes a new AVR with a super
> duper MDU built-in...
>

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.

If you can stick to division by constants, gcc will generate good code by
multiplying by the reciprical.  Otherwise the library routines with gcc are
pretty good - you can be sure that your avr will do divisions in software
far faster than your old 8051 does them in "hardware".






reply via email to

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