Re: What micros do you actually hate to work with?
- From: Joerg <notthisjoergsch@xxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 10 Oct 2006 22:42:48 GMT
Hello Frank,
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:
A very bad example. This has nothing to do with C or ASM, but shows
an example where you need to solve a problem with minimal resources.
In which case a clever approach is needed. In C, you would have to be
equally clever, so it would look more or less the same. Something like
this perhaps:
register int16 twelve;
register int16 thirteen;
....
thirteen=twelve;
twelve=>>2;
thirteen+=twelve; // X1=X*2^-2+X
twelve=>>2;
thirteen+=twelve; // X2=X1*2^-2+X
twelve=>>4;
thirteen+=twelve; // X3=X2*2^-4+X
Etcetera.
Would compile to the same assembly code. The compiler will
optimize the shift by a constant to a number of single shifts,
no worries about that.
Yeah, Wilco showed me.
Generally speaking, asm is dead. Generally, using C will produce
better code in less time. Generally, with less than tiny asm
projects, a C version will give you a smaller footprint.
Generally, using asm is a waste of time and energy and
produces lower quality code.
Not dead at all. There are cases where you must be sure to control something in x machine cycles plus/minus zero. But that would be more like using the uC as a logic chip.
Now that was a stupid example.
Ok, ok....
--
Regards, Joerg
http://www.analogconsultants.com
.
- Follow-Ups:
- Re: What micros do you actually hate to work with?
- From: Walter Banks
- Re: What micros do you actually hate to work with?
- From: Ulf Samuelsson
- Re: What micros do you actually hate to work with?
- From: Frank Bemelman
- Re: What micros do you actually hate to work with?
- References:
- What micros do you actually hate to work with?
- From: hsmith
- Re: What micros do you actually hate to work with?
- From: Vladimir Vassilevsky
- Re: What micros do you actually hate to work with?
- From: Roman
- Re: What micros do you actually hate to work with?
- From: steve
- Re: What micros do you actually hate to work with?
- From: Roman
- Re: What micros do you actually hate to work with?
- From: steve
- Re: What micros do you actually hate to work with?
- From: CBFalconer
- Re: What micros do you actually hate to work with?
- From: Didi
- Re: What micros do you actually hate to work with?
- From: PhilW
- Re: What micros do you actually hate to work with?
- From: Didi
- Re: What micros do you actually hate to work with?
- From: Ulf Samuelsson
- Re: What micros do you actually hate to work with?
- From: Joerg
- Re: What micros do you actually hate to work with?
- From: Frank Bemelman
- What micros do you actually hate to work with?
- Prev by Date: Re: What micros do you actually hate to work with?
- Next by Date: Re: What micros do you actually hate to work with?
- Previous by thread: Re: What micros do you actually hate to work with?
- Next by thread: Re: What micros do you actually hate to work with?
- Index(es):
Relevant Pages
|