* src/z80/gen.c: Fixed up generator to pass the regresion tests, specifically fixing...
[fw/sdcc] / support / tests / dhrystone / dhry.c
index 35f446726c50d3bc3c8a79a9d326106d17fecd0e..52cdb647b2335ecafc98ccf7e4cab59906b8eaa9 100644 (file)
 /** For printf */
 #include <stdio.h>
 
-#ifdef SDCC_ds390
+#if defined(SDCC_ds390)
 #include <tinibios.h>
 #define clock() ClockTicks()
 #define CLOCKS_PER_SEC 1000
-#undef PRINT_T_STATES
 #define memcpy(d,s,l) memcpyx(d,s,l)
+
+#elif defined(__z80) || defined(__gbz80)
+unsigned int _clock(void);
+
+#define clock _clock
+#define CLOCKS_PER_SEC 100
+
 #else
 /** For clock() */
 #include <time.h>
 #include <types.h>
-#define PRINT_T_STATES
-#endif
-
-/** Print the number of t-states this program has been executing for.
-    Optional :)
-*/
-#ifdef PRINT_T_STATES
-void _printTStates(void);
 #endif
 
 /** Set to one to print more messages about expected values etc. 
@@ -90,6 +88,10 @@ int             Arr_2_Glob [50] [50];
 /* Used instead of malloc() */
 static Rec_Type _r[2];
 
+void mark(void)
+{
+}
+
 void Proc_1 (REG Rec_Pointer Ptr_Val_Par);
 void Proc_2 (One_Fifty *Int_Par_Ref);
 void Proc_5 (void);
@@ -141,9 +143,9 @@ int main(void)
 
     /* 32766 is the highest value for a 16 bitter */
 #if DEBUG
-    Number_Of_Runs = 3;
+    Number_Of_Runs = 3000;
 #else
-    Number_Of_Runs = 10000;
+    Number_Of_Runs = 32766;
 #endif    
 
     runTime = clock();
@@ -218,10 +220,6 @@ int main(void)
        DPRINTF(("Looping.\n"));
     } /* loop "for Run_Index" */
 
-#ifdef PRINT_T_STATES    
-    _printTStates();
-#endif    
-
     printf("Run_Index = %d\n", Run_Index);
 
     runTime = clock() - runTime;
@@ -282,12 +280,18 @@ int main(void)
     printf ("        should be:   DHRYSTONE PROGRAM, 2'ND STRING\n");
     printf ("\n");
 #endif
-    printf("Dhrystones/s = %lu\n", (unsigned long)Number_Of_Runs / (runTime/CLOCKS_PER_SEC));
+#if 1
+    printf("Number of runs: %u.  runTime: %u.\n", Number_Of_Runs, (unsigned)runTime);
+    mark();
+    printf("Dhrystones/s = %u\n", (unsigned)((unsigned long)Number_Of_Runs / (runTime/CLOCKS_PER_SEC)));
     printf("MIPS = d/s/1757 = (sigh, need floats...)\n");
+#endif
 #ifdef PRINT_T_STATES    
     _printTStates();
 #endif    
+#if 1
     printf("Time: %lu ticks\n", runTime);
+#endif
 }
 
 void Proc_1 (REG Rec_Pointer Ptr_Val_Par)