Re: What micros do you actually hate to work with?



Hello Ulf,


How many projects in C have you managed to put into 1k.
I am saying what I am saying, my try seems successfull enough.

Have several complete C projects for customers that fit into an ATtiny13...
The latest project (not functional) was totally written in assembly
language,
and after rewriuting it in C, I managed to reduce the code by 10%.
Writing in assembler is generally a waste of time on an AVR...


Ok, I have only used '51 family device from Atmel, don't know if there are 16-bitters in store anywhere. But your word "generally" urges me to ask you how this multiplication by 0.457358479 (Horner + CSD optimized) would be done in C on a uC without HW multiplier in less than 30 CPU clocks:


mov.w R12,R13
rra.w R13
rra.w R13
add.w R12, R13 ; X1=X*2^-2+X
rra.w R13
rra.w R13
add.w R12, R13 ; X2=X1*2^-2+X
rra.w R13
rra.w R13
rra.w R13
rra.w R13
add.w R12, R13 ; X3=X2*2^-4+X
rra.w R13
rra.w R13
add.w R12, R13 ; X4=X3*2^-2+X
rra.w R13
rra.w R13
sub.w R12,R13 ; X5=X4*2^-2-X
rra.w R13
rra.w R13
rra.w R13
add.w R12, R13 ; X6=X5*2^-3+X
rra.w R13 ; Final output=X6*2^-1


On an 8-bitter this would take a few more cycles but probably not more than another 10.

--
Regards, Joerg

http://www.analogconsultants.com
.



Relevant Pages

  • Re: What micros do you actually hate to work with?
    ... I am saying what I am saying, ... Have several complete C projects for customers that fit into an ATtiny13... ... Writing in assembler is generally a waste of time on an AVR... ... rra.w R13 ...
    (comp.arch.embedded)
  • Re: Name of caller function
    ... I can't see how profile would help. ... I found an old post here saying that ... On the version of Matlab I'm using, (R13) it just gives the mfilename ...
    (comp.soft-sys.matlab)
  • Re: What micros do you actually hate to work with?
    ... I am saying what I am saying, ... Have several complete C projects for customers that fit into an ATtiny13... ... Once when I asked a C-programmer that I needed something like this and gave him a rough sketch in assembler he frowned and said he'd have to sow that in as inline assembler. ...
    (comp.arch.embedded)