Image Map Image Map
Results 1 to 3 of 3

Thread: Tips on C64 chain-loading with ML

  1. #1
    Join Date
    Apr 2011
    San Francisco, CA

    Default Tips on C64 chain-loading with ML

    Hi all,

    I'm working on some C64 software, and was interested in chain-loading programs with ML. Specifically, I have a menu program which allows you to select between a few different options, then I would like to load and jump to the start of the new program. Would also like to persist a few bytes of state between these, so I could stash this in memory somewhere.

    I experimented a bit using the LOAD kernal routine, but wondering about the right way to jump to the beginning of the newly loaded program. One idea was to stash a tiny loader somewhere safe in memory which would manage the transition between loads, i.e. jump to the loader from the menu program, load the new program, then jump to the start address.

    Just wanted to see if anyone had tips or examples doing something like this. I'm using cc65 for compiling my various .prgs, with inline assembler when needed. Thanks!

  2. #2


    I don't JMP, I JSR.

    Most programs RTS at the end to return to the OS. They don't need to know that they are returning to something other than the OS, usually.

    In fact there's a common exploit used on the C64 where a program does expect to return to BASIC. Write a BASIC command on the screen and load the keyboard buffer with carriage returns or short commands. That's why when I call an unexpected program, I reset the keyboard buffer on return. But it sounds like you're not going to run into that.

    The biggest trouble with doing these things on the C64 is that most programs out there make the assumption that the system started in a warm boot state and that they have free use of the entire address space.

  3. #3


    Maybe it would be easier to start with how you envision control flow going. It sounds like what you're asking for is some sort of overlay system.
    I use my C128 because I am an ornery, stubborn, retro grouch. -- Bob Masse
    Machine room updated for 2019!:


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts