Skip to content

overengineered code in C for CC65 ;-) #2

@ilmenit

Description

@ilmenit

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions