/* --------------------------------------------------------------------------
Name:       batterylife.c
Function:   Study in performance.  Three functions are created to perform
the same operation.  Each performs it differently.
To see code size:
   Options:    C/C++ Compiler->List->output list file
               Linker->List-generate linker listing
To see execution time:
   In debugger, select View->Pprofiling.  Turn on profiling, run, break, 
   update profile numbers.  

            Code Size   Cycles
sample1()      ?        ?
sampel2()      ?        ?
sample3()      ?        ?
----------------------------------------------------------------------------- */
#include <msp430x20x3.h>
#define  ARRAY_SIZE  10

unsigned int array[ARRAY_SIZE];
unsigned int array2[ARRAY_SIZE];

extern void sample1(void);
extern void sample2(void);
extern void sample3(void);


void main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                  // Stop watchdog timer

  while (1)
  {
     sample1();
     sample2();
     sample3();
  };
}


void sample1(void)
{
  char  i;
   
  for (i=0; i<ARRAY_SIZE; i++)
  {
     array[i] = (array2[i] * 5)/40;
  }
}
void sample2(void)
{
  char  i;

  for (i=0; i<ARRAY_SIZE; i++)
  {
     array[i] = array2[i]/8;
  }
}
void sample3(void)
{
  array[0] = array2[0]/8;
  array[1] = array2[1]/8;
  array[2] = array2[2]/8;
  array[3] = array2[3]/8;
  array[4] = array2[4]/8;
  array[5] = array2[5]/8;
  array[6] = array2[6]/8;
  array[7] = array2[7]/8;
  array[8] = array2[8]/8;
  array[9] = array2[9]/8;
}  
  

