--- /dev/null
+#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
+}
+
+
--- /dev/null
+extern void Timer2Handler (void) interrupt 5 using 1;
+extern unsigned long clock(void);
+extern void startTimer(void);
+
+#define CLOCKS_PER_SEC 1000
#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.
*/
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];
/* 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();
DPRINTF(("Looping.\n"));
} /* loop "for Run_Index" */
+#ifdef PRINT_T_STATES
_printTStates();
+#endif
printf("Run_Index = %d\n", Run_Index);
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)
}
} /* if Ch_Loc */
} /* Func_2 */
+
--- /dev/null
+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) $<