emuspeed.c revision 1.1
11.1Sis#include <setjmp.h>
21.1Sis#include <signal.h>
31.1Sis#include <stdlib.h>
41.1Sis#include <stdio.h>
51.1Sis#include <time.h>
61.1Sis#include <unistd.h>
71.1Sis
81.1Sis#include "speed.h"
91.1Sis
101.1Sisconst struct test {
111.1Sis	char *name;
121.1Sis	void (*func)__P((int));
131.1Sis	char *comment;
141.1Sis	int count;
151.1Sis} testlist[] = {
161.1Sis	{"Illegal", illegal, "(test: unimplemented)", 1},
171.1Sis	{"mulsl Da,Db", mul32sreg, "(test: should be native)", 200000000},
181.1Sis	{"mulsl sp@(8),Da", mul32smem, "(test: should be native)\n",
191.1Sis	    200000000},
201.1Sis
211.1Sis	{"mulsl Dn,Da:Db", mul64sreg, "emulated on 68060", 2000000},
221.1Sis	{"mulul Dn,Da:Db", mul64ureg, "\t\"", 2000000},
231.1Sis	{"mulsl sp@(8),Da:Db", mul64smem, "\t\"", 1000000},
241.1Sis	{"mulul sp@(8),Da:Db", mul64umem, "\t\"\n", 1000000},
251.1Sis
261.1Sis	{"divsl Da:Db,Dn", div64sreg, "\t\"", 500000},
271.1Sis	{"divul Da:Db,Dn", div64ureg, "\t\"", 500000},
281.1Sis	{"divsl Da:Db,sp@(8)", div64smem, "\t\"", 300000},
291.1Sis	{"divul Da:Db,sp@(8)", div64umem, "\t\"\n", 300000},
301.1Sis
311.1Sis	{NULL, NULL, NULL}
321.1Sis};
331.1Sis
341.1Sisjmp_buf jbuf;
351.1Sisvoid illhand (int);
361.1Sis
371.1Sisint
381.1Sismain(argc, argv)
391.1Sis	int argc;
401.1Sis	char *argv[];
411.1Sis{
421.1Sis	const struct test *t;
431.1Sis	clock_t start, stop;
441.1Sis
451.1Sis
461.1Sis	if (signal(SIGILL, &illhand))
471.1Sis		warn("%s: can't install illegal instruction handler.",
481.1Sis		    argv[0]);
491.1Sis
501.1Sis	printf("Speed of instructions which are emulated on some cpus:\n\n");
511.1Sis	(void)sleep(1);
521.1Sis	for (t=testlist; t->name; t++) {
531.1Sis		printf("%-20s", t->name);
541.1Sis		fflush(stdout);
551.1Sis
561.1Sis		if (setjmp(jbuf)) {
571.1Sis			printf("%15s    %s\n", "[unimplemented]", t->comment);
581.1Sis			continue;
591.1Sis		}
601.1Sis
611.1Sis		start = clock();
621.1Sis		t->func(t->count);
631.1Sis		stop = clock();
641.1Sis		printf("%13d/s    %s\n",
651.1Sis		    CLOCKS_PER_SEC*(t->count /(stop - start)),
661.1Sis		    t->comment);
671.1Sis	}
681.1Sis	exit (0);
691.1Sis}
701.1Sis
711.1Sisvoid
721.1Sisillhand(int i)
731.1Sis{
741.1Sis	longjmp(jbuf, 1);
751.1Sis}
76