Jump to content
Harry Potter

Atari 8/cc65 cubbyhole optimization?

Recommended Posts

Hi!  I have an optimization technique called the Cubbyhole technique and been using it to optimize cc65 programs for CBM targets.  The Cubbyhole technique involves filling unused parts of the OS's used RAM with code.  I've been perusing the Mapping the Atari e-text for such memory and found the cassette buffer and unused BASIC RAM.  I want to load the code as a chunk in an executable before the main module and have it exit immediately.  How do I do this?

Share this post


Link to post
Share on other sites

if you look at the load structure for atari binaries, you will see that it is composed of segments preceded by a header that indicate the location to load to, the length, and whether you want to execute something after load. CC65's linker configuration can allow you to specify these segments in your output, or you could create them manually in some kind of post-compilation script.
I think people usually use things like the cassette buffer as places to move/relocate small bits of code manually after having loaded them into a more usual location. There are a few places you can more or less count on, but the memory layouts for various atari hardware, OS's, and DOS's can be kind of variant, and unless your plan is to only emit programs that take over the whole machine, I think a optimization strategy that counts on lots of little bits and pieces being consistently unused across the board might be difficult to generalize.
 

Share this post


Link to post
Share on other sites
1 hour ago, Harry Potter said:

I want to load the code as a chunk in an executable before the main module and have it exit immediately.  How do I do this?

What do you want to "exit immediately" (the "chunk" or the main module) and what do you mean by "exit immediately" - after executing some instructions in the chunk before the main module or that the "chunk" contains only data and does nothing?

 

If the latter, you just load the chunk without execution.

Share this post


Link to post
Share on other sites

I want the code in the tape buffer to exit immediately, as t is not yet run.  By "exit immediately" I mean an RTS instruction: the code is only executed by the main module.   How do I define the trailer of a chunk?

Share this post


Link to post
Share on other sites
1 hour ago, Harry Potter said:

By "exit immediately" I mean an RTS instruction:

If so, why you want it to be executed at all? Load it without execution. You do not need a "trailer" for that, just the header and data block to load.

 

Share this post


Link to post
Share on other sites

I don't.  I thought from the Atari programming files in cc65 that I needed to provide a direct RTS to not execute the chunk.  One more question: 1. How do I not provide the trailer?

Share this post


Link to post
Share on other sites

Hi!

1 hour ago, Harry Potter said:

I don't.  I thought from the Atari programming files in cc65 that I needed to provide a direct RTS to not execute the chunk.  One more question: 1. How do I not provide the trailer?

Your questions are about CC65, not about the Atari 🙂 

 

The Atari "XEX" file format does not have a trailer, it only has (posible multiple) chunk headers. What you name the trailer is actually the last chunk, this writes address RUNAD so the DOS jumps to that location to run your binary.

 

To write arbitrary chunks in CC65, you must write a custom linker config file, I recommend you start with the "atari-asm-xex.cfg" file if writing assembly programs or "atari-xex.cfg" if writing C programs. In the XEX output format, each MEMORY area in the linker will be written as a separate chunk in the output file, so you simply define multiple MEMORY areas for all the memory you want to use.

 

Have Fun!

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...