Need 286 "C" benchmark
Darrell Long
darrell at sdcsvax.UUCP
Wed May 29 14:20:15 AEST 1985
Here's a little program that makes a good benchmark. It especially
exercises the CALL instruction, clearly on of the most used of all
instructions.
This program finds the Knight's tour on an n*n chess board, I
suggest you start with n=5. The running times grow exponentially
in n.
I have run this program on 68010's (SUN), WE-3200x (3B-2) and VAXen
with interesting results. Let's see how the 80286 fares.
#include <stdio.h>
#define TRUE 1
#define FALSE !TRUE
#define n 5
#define n_sqr n*n
int a[8]={2,1,-1,-2,-2,-1,1,2};
int b[8]={1,2,2,1,-1,-2,-2,-1};
int chess_board[n][n];
int count = 0;
main()
{
int i,j;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
chess_board[i][j] = 0;
chess_board[0][0] = 1;
if (try(2,0,0))
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
printf("\t%d",chess_board[i][j]);
printf("\n");
}
else
printf("no solution in %d tries.\n", count);
}
try(i,x,y)
int i,x,y;
{
int k,u,v,q_1;
k = 0;
do {
count++;
q_1 = FALSE;
u = x + a[k];
v = y + b[k];
if (((u < n) && (u >= 0)) && ((v < n) && (v >= 0)))
if (chess_board[u][v] == 0) {
chess_board[u][v] = i;
if (i < n_sqr)
{
q_1 = try((i + 1),u,v);
if (!q_1) chess_board[u][v] = 0;
}
else
q_1 = TRUE;
};
}
while ((!q_1) && (++k < 8));
return(q_1);
}
--
Darrell Long
Department of Electrical Engineering and Computer Science
University of California, San Diego
USENET: sdcsvax!darrell
ARPA: darrell at sdcsvax
More information about the Comp.lang.c
mailing list