Add TINI target
authorkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 16 Sep 2000 05:38:26 +0000 (05:38 +0000)
committerkvigor <kvigor@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 16 Sep 2000 05:38:26 +0000 (05:38 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@361 4a8a32a2-be11-0410-ad9d-d568d2c75423

support/tests/dhrystone/clock.c [new file with mode: 0644]
support/tests/dhrystone/clock.h [new file with mode: 0644]
support/tests/dhrystone/dhry.c
support/tests/dhrystone/tini.mak [new file with mode: 0644]

diff --git a/support/tests/dhrystone/clock.c b/support/tests/dhrystone/clock.c
new file mode 100644 (file)
index 0000000..0c01a78
--- /dev/null
@@ -0,0 +1,41 @@
+#include <ds80c390.h>
+#include <stdio.h>
+
+#include "clock.h"
+
+volatile unsigned long milliSeconds=0;
+
+#define RELOAD_VALUE 18432000/2/CLOCKS_PER_SEC 
+
+void Timer2Handler (void) interrupt 5 using 1 {
+  TF2=0; // reset overflow flag
+  milliSeconds++;
+  // that's all for now :)
+}
+
+// we can't just use milliSeconds
+unsigned long clock(void) {
+  unsigned long ms;
+  ET2=0;
+  ms=milliSeconds;
+  ET2=1;
+  return ms;
+}
+
+void startTimer (void) 
+{
+  printf ("\n\rStarting timer 2 test.\n\r");
+
+  // initialise timer
+  ET2=0; // disable timer interrupts initially
+  T2CON=0; // stop, timer mode, autoreload
+  T2MOD&=0xf4;
+  
+  TL2=RTL2=(-RELOAD_VALUE)&0xff;
+  TH2=RTH2=(-RELOAD_VALUE)>>8;
+  TR2=1; // run
+
+  ET2=1; // enable timer interrupts
+}
+
+
diff --git a/support/tests/dhrystone/clock.h b/support/tests/dhrystone/clock.h
new file mode 100644 (file)
index 0000000..2d395dc
--- /dev/null
@@ -0,0 +1,5 @@
+extern void Timer2Handler (void) interrupt 5 using 1;
+extern unsigned long clock(void);
+extern void startTimer(void);
+
+#define CLOCKS_PER_SEC 1000
index 859a88c770ad9ee216c0d083e461a9053999dd08..a6e6dd47444871336fd868bd56980682fb6f701d 100644 (file)
 #include <string.h>
 /** For printf */
 #include <stdio.h>
+
+#ifdef SDCC_ds390
+#include "clock.h"
+#include <serial390.h>
+#undef PRINT_T_STATES
+#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. 
  */
@@ -104,8 +114,12 @@ int main(void)
     Str_30          Str_2_Loc;
     REG   int             Run_Index;
     REG   int             Number_Of_Runs;
-    unsigned runTime;
+    unsigned  long runTime;
 
+#ifdef SDCC_ds390
+    startTimer();
+#endif
+    
     printf("[dhry]\n");
 
     Next_Ptr_Glob = &_r[0];
@@ -128,7 +142,11 @@ int main(void)
     /* overflow may occur for this array element.                   */
 
     /* 32766 is the highest value for a 16 bitter */
+#if DEBUG
+    Number_Of_Runs = 3;
+#else
     Number_Of_Runs = 10000;
+#endif    
 
     runTime = clock();
 
@@ -202,7 +220,9 @@ int main(void)
        DPRINTF(("Looping.\n"));
     } /* loop "for Run_Index" */
 
+#ifdef PRINT_T_STATES    
     _printTStates();
+#endif    
 
     printf("Run_Index = %d\n", Run_Index);
 
@@ -266,10 +286,12 @@ int main(void)
     printf ("        should be:   DHRYSTONE PROGRAM, 2'ND STRING\n");
     printf ("\n");
 #endif
-    printf("Dhrystones/s = %u\n", Number_Of_Runs / (runTime/CLOCKS_PER_SEC));
+    printf("Dhrystones/s = %lu\n", (unsigned long)Number_Of_Runs / (runTime/CLOCKS_PER_SEC));
     printf("MIPS = d/s/1757 = (sigh, need floats...)\n");
+#ifdef PRINT_T_STATES    
     _printTStates();
-    printf("Time: %u ticks\n", runTime);
+#endif    
+    printf("Time: %lu ticks\n", runTime);
 }
 
 void Proc_1 (REG Rec_Pointer Ptr_Val_Par)
@@ -541,3 +563,4 @@ Boolean Func_2 (char *Str_1_Par_Ref, char *Str_2_Par_Ref)
            }
        } /* if Ch_Loc */
 } /* Func_2 */
+
diff --git a/support/tests/dhrystone/tini.mak b/support/tests/dhrystone/tini.mak
new file mode 100644 (file)
index 0000000..be9bbac
--- /dev/null
@@ -0,0 +1,21 @@
+CC = sdcc
+
+MFLAGS = -mds390 --model-flat24 --stack-10bit
+MFLAGS += -DREG= -DNOSTRUCTASSIGN -DNOENUM
+LFLAGS = --xram-loc 0x180000 --code-loc 0x10000 -Wl-r
+
+OBJECTS = dhry.rel clock.rel
+
+all: dhry.hex
+
+clean:
+       rm -f *~ \#* *.asm *.cdb *.rel *.hex *.ihx *.lst *.map *.rst *.sym *.lnk
+
+dhry.hex: dhry.ihx
+       packihx dhry.ihx >dhry.hex
+
+dhry.ihx: $(OBJECTS)
+       $(CC) $(MFLAGS) $(LFLAGS) $(OBJECTS)
+
+%.rel: %.c
+       $(CC) -c $(MFLAGS) $<