Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!IDCSVAX.BITNET!AMONSON From: AMONSON@IDCSVAX.BITNET Newsgroups: comp.sys.atari.8bit Subject: Sieve bench source (cc65) Message-ID: <8911300807.AA08804@ucbvax.Berkeley.EDU> Date: 29 Nov 89 21:31:00 GMT Sender: usenet@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 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