From 524ad55f329e9182e252f628cdf964a5fe574ffa Mon Sep 17 00:00:00 2001 From: kvigor Date: Sat, 16 Sep 2000 05:38:26 +0000 Subject: [PATCH] Add TINI target git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@361 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- support/tests/dhrystone/clock.c | 41 ++++++++++++++++++++++++++++++++ support/tests/dhrystone/clock.h | 5 ++++ support/tests/dhrystone/dhry.c | 29 +++++++++++++++++++--- support/tests/dhrystone/tini.mak | 21 ++++++++++++++++ 4 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 support/tests/dhrystone/clock.c create mode 100644 support/tests/dhrystone/clock.h create mode 100644 support/tests/dhrystone/tini.mak diff --git a/support/tests/dhrystone/clock.c b/support/tests/dhrystone/clock.c new file mode 100644 index 00000000..0c01a783 --- /dev/null +++ b/support/tests/dhrystone/clock.c @@ -0,0 +1,41 @@ +#include +#include + +#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 index 00000000..2d395dca --- /dev/null +++ b/support/tests/dhrystone/clock.h @@ -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 diff --git a/support/tests/dhrystone/dhry.c b/support/tests/dhrystone/dhry.c index 859a88c7..a6e6dd47 100644 --- a/support/tests/dhrystone/dhry.c +++ b/support/tests/dhrystone/dhry.c @@ -47,14 +47,24 @@ #include /** For printf */ #include + +#ifdef SDCC_ds390 +#include "clock.h" +#include +#undef PRINT_T_STATES +#else /** For clock() */ #include #include +#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 index 00000000..be9bbacc --- /dev/null +++ b/support/tests/dhrystone/tini.mak @@ -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) $< -- 2.47.2