Harry Potter Posted January 30, 2021 Share Posted January 30, 2021 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? Quote Link to comment Share on other sites More sharing options...
danwinslow Posted January 30, 2021 Share Posted January 30, 2021 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. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted January 30, 2021 Author Share Posted January 30, 2021 I looked at the Atari 8 library modules and know the module header but not the trailer. How do I define the trailer? Quote Link to comment Share on other sites More sharing options...
drac030 Posted January 30, 2021 Share Posted January 30, 2021 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. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted January 30, 2021 Author Share Posted January 30, 2021 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? Quote Link to comment Share on other sites More sharing options...
drac030 Posted January 30, 2021 Share Posted January 30, 2021 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. Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted January 30, 2021 Author Share Posted January 30, 2021 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? Quote Link to comment Share on other sites More sharing options...
dmsc Posted January 30, 2021 Share Posted January 30, 2021 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! Quote Link to comment Share on other sites More sharing options...
Harry Potter Posted January 30, 2021 Author Share Posted January 30, 2021 So just don't put the trailer. Thank you! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.