[comp.sys.atari.8bit] Sieve bench source

AMONSON@IDCSVAX.BITNET (11/30/89)

Charles Green (or any interested parties; I couldn't reach your address),

This is the C code that I used for my sieve speed test on the cc65 compiler.
From what I know about Action!, the conversion should be fairly simple.  The
code may look familiar, I think it originated from the cc8 distribution...

    o /
---- X ---- Cut Here ----------------------------------------------------------
    O \

#define TRUE  1
#define FALSE 0
#define SIZE  8190

char flags[SIZE+1];

char start[3], stop[3];

main ()
{
  int i, prime, k, count, iter, total;

  printf("10 iterations\n");
  total = 0;

  for (iter=1; iter<=10; iter++)
  {
    printf("iter %d\n", iter);

    gtime(start);

    count = 0;

    for (i=0; i<=SIZE; i++)
      flags[i] = TRUE;

    for (i=0; i<=SIZE; i++)
    {
      if (flags[i])
      {
        prime = i+i+3;
        for (k=i+prime; k<=SIZE; k+=prime)
          flags[k] = FALSE;
        count++;
      }
    }

    gtime(stop);

    printf("Start: %x, %x, %x\n",
      (int)start[2],
      (int)start[1],
      (int)start[0]);
    printf(" Stop: %x, %x, %x\n",
      (int)stop[2],
      (int)stop[1],
      (int)stop[0]);
  }

  printf("\gDone!\g\n");
}

gtime (time)
char *time;
{
  time[0] = *((char *) 0x12);
  time[1] = *((char *) 0x13);
  time[2] = *((char *) 0x14);
}

    o /
---- X ---- Cut Here ----------------------------------------------------------
    O \

I have used the curly braces instead of "$(" and "$)" (I use textpro with a
TEXTPRO.FNT file defining the characters.)  I don't know what the Action!
editor will do with these.  I calculated the running time by hand using a
hex calculator.  The gtime() function should have been in pure 6502 code with
interupts shut off.  I didn't check what this code compiles to, but it may be
slow enough to get a bad reading from the jiffy clock rolling over midway
through.  In my 10 iterations I never had obvious bad data, so I left it.

Have Fun!  It will be interesting to see the results.


Duane Tribe, University of Idaho

Internet: tribe@ed.cs.uidaho.edu (129.101.100.25)
My benefactor on BITNET: amonson@idcsvax