4 comments on “Amateur Optimization Hour, part 2

  1. > To do that, I just had to ask CC65 to write the assembly output to a file – there’s even an option to include the original C code as inline comments. Then I took the functions I was interested in (DrawMapSection and DrawBlankMapSection, to start) and put them in a .asm file. Of course, it wouldn’t compile right away.

    If you would have separated DrawMapSection and DrawBlankMapSection to an own C file, made everything build again and then taken that .asm file as a starting point for optimization you wouldn’t have had that problem. After all the cc65 C compiler _only_ generates those .asm files and needs the cc65 assembler assemble them – so they are known to work out of the box.

    • Yeah, that totally makes sense. I’ve been doing a unity build for this project, but in this case I guess I made some extra work for myself!

  2. > Implementation variables. Finally, there are “variables” that are used internally by CC65 for the code it generates. They include a number of the imported symbols mentioned above like ptr1, sp, and regsave. It would probably be a terrible idea to use those memory locations myself, and anything I do could easily be broken in an update to the compiler. But that doesn’t mean I’m not gonna do it.

    Not at all. https://github.com/cc65/wiki/wiki/Using-runtime-zeropage-locations-in-assembly-language describes which variable can be used when by whom. This information can be considered stable.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s