[Q] running a prg from C (or asm)

Basic and Machine Language

Moderator: Moderators

User avatar
Mike
Herr VC
Posts: 4816
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Post by Mike »

pallas wrote:

Code: Select all

#elif defined(__C64__)
//POKEW(47, size);  optional
//POKEW(49, size);  optional
  asm("jsr $E518");  // Initialize I/O
  asm("jsr $E453");  // initialize vectors
  asm("jsr $E3BF");  // initialize basic ram

// currently doesn't work: looks like it crashes before doing the relink

  asm("jsr $A659");  // clr + reset stack
  asm("jsr $A533");  // relink basic code
  asm("jmp $A7AE");  // run
#endif
works on vic-20 but crashes (like if you run/stop+restore) on c64.
Depending on the settings in the *.cfg file you're using for the C64, cc65 banks out the BASIC ROM for continuous RAM from $0800 to $CFFF.

If you set the CPU port register $01 to the standard value (#$37) between these two groups of JSRs, it should work.

Of course, this relies upon that the code in question itself isn't made invisible as it's overlaid by the BASIC ROM, also the rest of the C program would expect the original memory configuration, but as these lines are the last to be executed by the C program, this shouldn't matter.
Post Reply