Commodore Machines - cc65/wiki GitHub Wiki

Common problems for assembler programmers (and workarounds)

For assembler programs, ca65 doesn't add the 2-byte load address when generating binaries for the Commodore machines. That load address is added automatically by most other assemblers. Since ca65 is not a Commodore-specific assembler, it doesn't do so, which means the program won't run when transfered to disk, or loaded in an emulator.

So, to add it manually, we need two things:

  • Add the address as the first word in the generated binary.
  • Be sure to correct the memory start address in the linker, since this address is part of the binary, but the actual code starts after it.
The former is done by adding
        .addr   *+2

We have to make sure this goes in front of everything else; so, when using segments, we must place it in its own segment, and tell the linker to add that segment as the first one in the binary. Or, if we aren't using segments (that is, everything goes into CODE), we just add it as the first code line.

The second measure is to account for the additional two bytes, in the linker config. If our code starts at $C000, we must account for the load address, and make the start address of the memory area $BFFE.

People who are used to other assemblers can find some more hints in the ca65 documentation.

⚠️ **GitHub.com Fallback** ⚠️