Hello, Vincent Trouilliez schrieb: > 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...
For such things it is interessting to use fixed point math. If you want to divide 200 data Bytes by 13 you can do fac = 256 / 13; (* Only one div needed *) for i := 0 to 199 do data[i] = data[i] shl 8 * fac; and you need only 1 div and man muls. For data-filters you normaly can avoid doing massiv divs. -Alex Wenger _______________________________________________ AVR-GCC-list mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/avr-gcc-list
