Loading a file into memory and then executing it (no operating system)

81 views Asked by At

My program (written in c) loads other programs into memory before executing them. This is the code I do that with:

void (*jumpToExec)(void) = (void (*)())0x0801;

void loadExecutable(char* executable) {
    cbm_k_setnam(executable);
    cbm_k_setlfs(0, 8, 0);
    cbm_k_load(1, 0x0801);

    jumpToExec();
}

(Please ignore the CBM-DOS calls, they are not relevant. They basically just identify a file and load it into memory)

executable, in this case, points to a program built from this code:

int otherMain() {
    printf("Hello, world!");

    return EXIT_SUCCESS;
}

How do I run the function otherMain() in this separate program when the function loadExecutable() in the main program loads it?

0

There are 0 answers