Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overengineered code in C for CC65 ;-) #2

Closed
ilmenit opened this issue Feb 17, 2020 · 1 comment
Closed

overengineered code in C for CC65 ;-) #2

ilmenit opened this issue Feb 17, 2020 · 1 comment

Comments

@ilmenit
Copy link

ilmenit commented Feb 17, 2020

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

@KarolS
Copy link
Owner

KarolS commented Aug 23, 2020

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!

@KarolS KarolS closed this as completed Aug 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants