#include typedef unsigned char U8; #define MEMSIZE (128*1024) #define CHUNKSIZE 8 // bytes U8 mem[MEMSIZE]; void find_repeat(void) { int start, comp1, comp2; int repcount; U8 firstbyte; for(start = 0; start < MEMSIZE - CHUNKSIZE; start += CHUNKSIZE) { repcount = 0; /* find how many times the memory at start is found in memory */ firstbyte = mem[start]; for(comp1 = 0; comp1 < MEMSIZE - CHUNKSIZE; comp1++) { if(mem[comp1] == firstbyte) { // quick optimization for(comp2 = 1; comp2