Esempio n. 1
0
void _premain()
{
	int t;
	unsigned long *pul;
	fptr f;

    UART_DATA = 0x31;
    UART_DATA = 0x2e;

//	__copy_data();
//	_initIO();
    __clear_bss();

    UART_DATA = 0x32;
    UART_DATA = 0x2e;

//    small_printf("\nCalling constructors...\n");

    pul = (unsigned long *)&__constructor_list;
    while(pul != (unsigned long *)&__end_of_constructors) {
//        small_printf("Constructor %p...\n", *pul);
        f = (fptr)*pul;
        f();
        pul++;
    }
        
    UART_DATA = 0x33;
    UART_DATA = 0x2e;

//    small_printf("\nStarting Main...\n");

	t=main(1, args);

    pul = (unsigned long *)&__end_of_destructors;
    do {
        pul--;
        if(pul < (unsigned long *)&__destructor_list)
        	break;
        small_printf("Destructor: %p...\n", *pul);
        f = (fptr)*pul;
        f();
    } while(1);

    small_printf("Done!\n");
//	exit(t);
//  for (;;);
}
Esempio n. 2
0
int main ()
/*****/

  /* main program, corresponds to procedures        */
  /* Main and Proc_0 in the Ada version             */
{
        One_Fifty       Int_1_Loc;
  REG   One_Fifty       Int_2_Loc;
        One_Fifty       Int_3_Loc;
  REG   char            Ch_Index;
        Enumeration     Enum_Loc;
  REG   int             Run_Index;

  /* Initializations */

	HW_PER(PER_UART_CLKDIV)=1250000/1152;

//  Next_Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));
//  Ptr_Glob = (Rec_Pointer) malloc (sizeof (Rec_Type));

  Next_Ptr_Glob = &rec1;
  Ptr_Glob = &rec2;

  Ptr_Glob->Ptr_Comp                    = Next_Ptr_Glob;
  Ptr_Glob->Discr                       = Ident_1;
  Ptr_Glob->variant.var_1.Enum_Comp     = Ident_3;
  Ptr_Glob->variant.var_1.Int_Comp      = 40;
  strcpy (Ptr_Glob->variant.var_1.Str_Comp, 
          "DHRYSTONE PROGRAM, SOME STRING");
  strcpy (Str_1_Loc, "DHRYSTONE PROGRAM, 1'ST STRING");

  Arr_2_Glob [8][7] = 10;
        /* Was missing in published program. Without this statement,    */
        /* Arr_2_Glob [8][7] would have an undefined value.             */
        /* Warning: With 16-Bit processors and Number_Of_Runs > 32000,  */
        /* overflow may occur for this array element.                   */
  small_printf ("\n");
  small_printf ("Dhrystone Benchmark, Version 2.1 (Language: C)\n");
  small_printf ("\n");
  if (Reg)
  {
    small_printf ("Program compiled with 'register' attribute\n");
    small_printf ("\n");
  }
  else
  {
    small_printf ("Program compiled without 'register' attribute\n");
    small_printf ("\n");
  }
  Number_Of_Runs;

  small_printf ("Execution starts, %d runs through Dhrystone\n", Number_Of_Runs);

  /***************/
  /* Start timer */
  /***************/

#if 0
#ifdef TIMES
  times (&time_info);
  Begin_Time = (long) time_info.tms_utime;
#endif
#ifdef TIME
  Begin_Time = time ( (long *) 0);
#endif
#else
  Begin_Time = _readMilliseconds();
#endif
  for (Run_Index = 1; Run_Index <= Number_Of_Runs; ++Run_Index)
  {
    Proc_5();
    Proc_4();
      /* Ch_1_Glob == 'A', Ch_2_Glob == 'B', Bool_Glob == true */
    Int_1_Loc = 2;
    Int_2_Loc = 3;
    strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 2'ND STRING");
    Enum_Loc = Ident_2;
    Bool_Glob = ! Func_2 (Str_1_Loc, Str_2_Loc);
      /* Bool_Glob == 1 */
    while (Int_1_Loc < Int_2_Loc)  /* loop body executed once */
    {
      Int_3_Loc = 5 * Int_1_Loc - Int_2_Loc;
        /* Int_3_Loc == 7 */
      Proc_7 (Int_1_Loc, Int_2_Loc, &Int_3_Loc);
        /* Int_3_Loc == 7 */
      Int_1_Loc += 1;
    } /* while */
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
    Proc_8 (Arr_1_Glob, Arr_2_Glob, Int_1_Loc, Int_3_Loc);
      /* Int_Glob == 5 */
    Proc_1 (Ptr_Glob);
    for (Ch_Index = 'A'; Ch_Index <= Ch_2_Glob; ++Ch_Index)
                             /* loop body executed twice */
    {
      if (Enum_Loc == Func_1 (Ch_Index, 'C'))
          /* then, not executed */
        {
        Proc_6 (Ident_1, &Enum_Loc);
        strcpy (Str_2_Loc, "DHRYSTONE PROGRAM, 3'RD STRING");
        Int_2_Loc = Run_Index;
        Int_Glob = Run_Index;
        }
    }
      /* Int_1_Loc == 3, Int_2_Loc == 3, Int_3_Loc == 7 */
    Int_2_Loc = Int_2_Loc * Int_1_Loc;
    Int_1_Loc = Int_2_Loc / Int_3_Loc;
    Int_2_Loc = 7 * (Int_2_Loc - Int_3_Loc) - Int_1_Loc;
      /* Int_1_Loc == 1, Int_2_Loc == 13, Int_3_Loc == 7 */
    Proc_2 (&Int_1_Loc);
      /* Int_1_Loc == 5 */

  } /* loop "for Run_Index" */

  /**************/
  /* Stop timer */
  /**************/
  
#if 0
#ifdef TIMES
  times (&time_info);
  End_Time = (long) time_info.tms_utime;
#endif
#ifdef TIME
  End_Time = time ( (long *) 0);
#endif
#else
  End_Time = _readMilliseconds();
#endif
  
  small_printf ("Execution ends\n");
  small_printf ("\n");
  small_printf ("Final values of the variables used in the benchmark:\n");
  small_printf ("\n");
  small_printf ("Int_Glob:            %d\n", Int_Glob);
  small_printf ("        should be:   %d\n", 5);
  small_printf ("Bool_Glob:           %d\n", Bool_Glob);
  small_printf ("        should be:   %d\n", 1);
  small_printf ("Ch_1_Glob:           %c\n", Ch_1_Glob);
  small_printf ("        should be:   %c\n", 'A');
  small_printf ("Ch_2_Glob:           %c\n", Ch_2_Glob);
  small_printf ("        should be:   %c\n", 'B');
  small_printf ("Arr_1_Glob[8]:       %d\n", Arr_1_Glob[8]);
  small_printf ("        should be:   %d\n", 7);
  small_printf ("Arr_2_Glob[8][7]:    %d\n", Arr_2_Glob[8][7]);
  small_printf ("        should be:   Number_Of_Runs + 10\n");
  small_printf ("Ptr_Glob->\n");
  small_printf ("  Ptr_Comp:          %d\n", (int) Ptr_Glob->Ptr_Comp);
  small_printf ("        should be:   (implementation-dependent)\n");
  small_printf ("  Discr:             %d\n", Ptr_Glob->Discr);
  small_printf ("        should be:   %d\n", 0);
  small_printf ("  Enum_Comp:         %d\n", Ptr_Glob->variant.var_1.Enum_Comp);
  small_printf ("        should be:   %d\n", 2);
  small_printf ("  Int_Comp:          %d\n", Ptr_Glob->variant.var_1.Int_Comp);
  small_printf ("        should be:   %d\n", 17);
  small_printf ("  Str_Comp:          %s\n", Ptr_Glob->variant.var_1.Str_Comp);
  small_printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
  small_printf ("Next_Ptr_Glob->\n");
  small_printf ("  Ptr_Comp:          %d\n", (int) Next_Ptr_Glob->Ptr_Comp);
  small_printf ("        should be:   (implementation-dependent), same as above\n");
  small_printf ("  Discr:             %d\n", Next_Ptr_Glob->Discr);
  small_printf ("        should be:   %d\n", 0);
  small_printf ("  Enum_Comp:         %d\n", Next_Ptr_Glob->variant.var_1.Enum_Comp);
  small_printf ("        should be:   %d\n", 1);
  small_printf ("  Int_Comp:          %d\n", Next_Ptr_Glob->variant.var_1.Int_Comp);
  small_printf ("        should be:   %d\n", 18);
  small_printf ("  Str_Comp:          %s\n",
                                Next_Ptr_Glob->variant.var_1.Str_Comp);
  small_printf ("        should be:   DHRYSTONE PROGRAM, SOME STRING\n");
  small_printf ("Int_1_Loc:           %d\n", Int_1_Loc);
  small_printf ("        should be:   %d\n", 5);
  small_printf ("Int_2_Loc:           %d\n", Int_2_Loc);
  small_printf ("        should be:   %d\n", 13);
  small_printf ("Int_3_Loc:           %d\n", Int_3_Loc);
  small_printf ("        should be:   %d\n", 7);
  small_printf ("Enum_Loc:            %d\n", Enum_Loc);
  small_printf ("        should be:   %d\n", 1);
  small_printf ("Str_1_Loc:           %s\n", Str_1_Loc);
  small_printf ("        should be:   DHRYSTONE PROGRAM, 1'ST STRING\n");
  small_printf ("Str_2_Loc:           %s\n", Str_2_Loc);
  small_printf ("        should be:   DHRYSTONE PROGRAM, 2'ND STRING\n");
  small_printf ("\n");

  User_Time = End_Time - Begin_Time;
  small_printf ("User time: %d\n", (int)User_Time);
  
  if (User_Time < Too_Small_Time)
  {
    small_printf ("Measured time too small to obtain meaningful results\n");
    small_printf ("Please increase number of runs\n");
    small_printf ("\n");
  }
/*   else */
  {
#if 0
#ifdef TIME
    Microseconds = (User_Time * Mic_secs_Per_Second )
                        /  Number_Of_Runs;
    Dhrystones_Per_Second =  Number_Of_Runs / User_Time;
    Vax_Mips = (Number_Of_Runs*1000) / (1757*User_Time);
#else
    Microseconds = (float) User_Time * Mic_secs_Per_Second 
                        / ((float) HZ * ((float) Number_Of_Runs));
    Dhrystones_Per_Second = ((float) HZ * (float) Number_Of_Runs)
                        / (float) User_Time;
    Vax_Mips = Dhrystones_Per_Second / 1757.0;
#endif
#else
    Microseconds = (1000*User_Time) / Number_Of_Runs;
    Dhrystones_Per_Second =  (Number_Of_Runs*1000) / User_Time;
    Vax_Mips = (Number_Of_Runs*569) / User_Time;
#endif 
    small_printf ("Microseconds for one run through Dhrystone: ");
    small_printf ("%d \n", (int)Microseconds);
    small_printf ("Dhrystones per Second:                      ");
    small_printf ("%d \n", (int)Dhrystones_Per_Second);
    small_printf ("VAX MIPS rating * 1000 = %d \n",(int)Vax_Mips);
    small_printf ("\n");
  }
  
  return 0;
}