indent test

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here is my fp benchmark. This is a test to see if code preserves the indents.....

//file fpbench.c
//test avr flops
//Mar 4 2003 Bob G (bobgardner@aol.com) compile w iccavr 6.27
//Jan 22 04 Bob G compile with iccavr 6.30
//Feb 4 04 Bob G add timer

#include 
#include 
#include 
#include 
#include 

#define INTR_OFF() asm("CLI")
#define INTR_ON()  asm("SEI")

extern void init_devices(void);
extern int _textmode;

//-----globals----------
unsigned int tofs;
unsigned long t1,t2;
unsigned long dt,ohdt,net;
int n,i,j;
float x,y,z;
float sec,flops;
char buf1[1024],buf2[1024];

//----------------------
#pragma interrupt_handler timer0_ovf_isr:17
void timer0_ovf_isr(void){
//tic=14745600/32=460800 tics/sec=4.34 usec/tic  (div=3) mega128 version
//256 tics=1 tof = 1111 usec
//65536 tofs=72 sec

  tofs++;    
}

//---------------------
unsigned long int gettics(void){
//return number of 4.34 usec tics
//1 tof=256 prescaled timer tics=1111usec  900 per sec
unsigned long tmp;

  INTR_OFF();
  tmp=((unsigned long)tofs << 8) + TCNT0;
  INTR_ON();
  return tmp;
}

#if 0
//-------------------------
unsigned char kbhit(void){
//return nonzero if char waiting   polled version
unsigned char b;

  b=0;
  if(UCSR0A & (1<<RXC0)) b=1;
  return b;
}

//-------------------------
unsigned char kbhit(void){
//return nonzero if char waiting  intr version
unsigned char b;

  b=rxindx != rxondx;
  return b;
}

//-----------------------
int getchar(void){
//intr version... overrides version in library
char c;

  while(!kbhit()){}; //wait for char
  c=rxbuf[rxondx++]; //get char from rxbuf
  if(rxondx > NUMCHAR-1) rxondx=0;
  return c;  
}

//------------------------------
#pragma interrupt_handler uart_rx_isr:12
void uart_rx_isr(void){
//uart has received a character in UDR  mega16version
char c;

  c=UDR0;            //get char from usart
  rxbuf[rxindx++]=c; //put char in rxbuf
  if(rxindx > NUMCHAR-1) rxindx=0;  
}

//-----------------------
int getchar(void){
//intr version... overrides version in library
char c;

  while(!kbhit()){}; //wait for char
  c=UDR0;
  return c;  
}

//-----------------------
int putc(char c){
//put char to usart0... dont add lf after cr   mega16 version

  while((UCSR0A & 0x20)==0){};	//0x20 is UDRE0. ==0 means data register full
  UDR0=c; //send char
  return c;
}

//----------------------  
int putchar(char c)	{
//adds lf after cr

  if(c=='\n'){
    putc('\r');
  }  
  putc(c);
  return c;
}
#endif

//----------------
void main(void){
//fpbench main program
char c;

  init_devices();
  _textmode=1;
    printf("\nfpbench Feb 4 2004 Bob Gardner\n");
  c=0;
  n=1000;
  while(c != 'q'){
    printf("\nbegin %u overhead loops\n",n);
	t1=gettics();
    for(i=0; i

Imagecraft compiler user