1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-08-09 20:25:17 +00:00
Files
kickc/src/test/kc/millfork-benchmarks/romsum-kc.c
2021-02-04 09:18:27 +01:00

41 lines
644 B
C

#include "benchcommon.c"
#include <c64-print.h>
byte* const rom = (byte*)0xe000;
unsigned int sum(void) {
unsigned int s;
byte* p;
byte page;
byte i;
byte tmp;
p = rom;
s = 0;
/* doing it page-by-page is faster than doing just one huge loop */
for (page = 0; page < 0x20; page++) {
i = 0;
do {
tmp = p[i];
s += tmp;
i++;
} while (i);
p += 0x100;
}
return s;
}
int main (void)
{
unsigned int i;
start();
for(i=0;i<6;i++) {
print_uint_decimal(sum());
print_ln();
}
end();
return 0;
}