Sergey, thanks for your explanation.
I understand the goal of __even_in_range. I saw in the IAR disassembled
code what it accomplishes. And I understand the need if the switch
statement actually had 34 case statements, but in this code there is
only one case statement. So, other than for educational reasons, I
don't see the value of spending my time trying to figure out how to
write the equivalent routine.
I did write a routine that confirms (at runtime) that the passed in
value is in range and is even (lsb is 0); in which case the value is
just passed back to the program, and if it does not meet these criterion
zero is passed back (again, at runtime). I could further improve this
routine by moving the code in the one lone case statement into the
assembler routine. And I would like to revisit this function at a later
date, for educational reasons and to eventually have an __even_in_range
function when needed for multiple case statements. But for the time
being I am content to move on to other more pressing issues that are
holding up the completion of my port of the eZChronos firmware to mspgcc4.
If I am making a mistake by passing on this for the moment, please point
it out to me.
Paul
On 6/14/2010 4:38 AM, Sergey A. Borshch wrote:
On 14.06.2010 5:50, Paul F. Sehorne wrote:
I wrote an assembly routine to emulate the intrinsic function
__even_in_range, and although it might work I doubt that it accomplishes
anything significant.
This function ensures the compiler that it's first argument is always even and
always in range [0...second argument]. So compiler allowed to generate case as
efficient table jump without additional checking of switch() statement.
And nothing more. You can just replace
switch(__even_in_range(ADC12IV,34))
to
switch(ADC12IV).
--
Paul
Sehorne owned or managed Web Sites
* Airport Homes <http://airporthomes.org/>
* Female Body Building <http://bodybuilding.sehorne.net/>
* Credit Repair <http://creditrepair.sehorne.net/>
* Personal Loans <http://personalloans.sehorne.net/>
* Shopping <http://shop.sehorne.net/>
* Hidden Valley Airpark <http://hiddenvalleyairpark.org/>