KarolS/millfork-benchmarks

overengineered code in C for CC65 ;-)

ilmenit opened this issue · 1 comments

Try this for 6502 / romsum.c in CC65, should be MUCH faster:

#include "benchcommon.h"
#include <conio.h>
#include <stdlib.h>

const unsigned char* const rom = (const unsigned char*)0xe000;

unsigned int sum(void) {
    register unsigned int s;
    register const unsigned char* p;
    s = 0;
    for (p = rom; p != 0; ++p)
    {
         s += *p;
    };
    return s;
}

int main (void)
{
    static unsigned char buffer[20];
    unsigned char i;
    start();
    for(i=0;i<6;i++) {
        utoa(sum(), buffer, 10);
	putchar(0x9b);
        cputs(buffer);
    }
    end();

    asm(" jmp *");

    return EXIT_SUCCESS;
}

Similarly, for SIEVE benchmark you can try this attachment - https://atariage.com/forums/topic/240919-mad-pascal/?do=findComment&comment=4434580

I applied optimizations to the C version and it runs better.
Sorry for not closing this earlier, it's been done months ago, but I haven't pushed the update to Github for months.

Thanks again for feedback!