Yaron Nir Posted January 26, 2019 Share Posted January 26, 2019 As i've added a new header c file to my project i started to get this error. i understand that the code i wrote must be big and now i am overflowing the memory area. can anyone suggest how do i fix this? thanks all Quote Link to comment Share on other sites More sharing options...
baktra Posted January 26, 2019 Share Posted January 26, 2019 One possibility is to change start address of your program. The default value is typically 8192, you can try decreasing it to 6144. You can do it by passing the -S 6144 option to the ld65 linker. Quote Link to comment Share on other sites More sharing options...
Yaron Nir Posted January 26, 2019 Author Share Posted January 26, 2019 playing a bit with the starting address solved this , but i fear going forward i will need to carefully plan the memory. cheers Quote Link to comment Share on other sites More sharing options...
baktra Posted January 27, 2019 Share Posted January 27, 2019 Planning the memory layout is a prudent measure. You can get more by fiddling with the starting address (if you go too low, your program might not be loadable from DOS, that might or might not be a way to go). Preparing your own linker.cfg file can help you to reduce stack size and get more memory, if possible, of course. Quote Link to comment Share on other sites More sharing options...
damosan Posted January 27, 2019 Share Posted January 27, 2019 ... Preparing your own linker.cfg ... This. I like cc65 but the linker config is a real pain when you're first starting to use the compiler. What linker config file are you using? 1 Quote Link to comment Share on other sites More sharing options...
baktra Posted January 27, 2019 Share Posted January 27, 2019 This. I like cc65 but the linker config is a real pain when you're first starting to use the compiler. What linker config file are you using? The linker has a steep learning curve, but it is worth the effort. But the question is rather for Yaron Nir. I am using tailored ones that are based on plain atari.cfg. When it comes to planning of the memory layout, the principal question is always the same: How much of DOS I need? 1. No DOS, my software can be loaded by a miniature binary loader from a disk/universal cart/tape. Then you can place code as low as 2048. 2. DOS only to load my software. Then you can use addresses 2048-... after your program is loaded. Exiting should be through cold start 3. DOS needed all the time. 2048-? must stay untouched. The question mark value depends on the size of given DOS. Could be 8192, 6144, or even 4096 for very small DOSes. Quote Link to comment Share on other sites More sharing options...
Yaron Nir Posted January 27, 2019 Author Share Posted January 27, 2019 I plan to run my software from a cartridge Not sure I need DOS I created several fixed memory allocations in my code so if I change my starting address I will need to align all the fixed memory accordingly otherwise code will crash I will try setting the starting address to 2048 as suggested above and re align fixed memory accordingly Quote Link to comment Share on other sites More sharing options...
baktra Posted January 27, 2019 Share Posted January 27, 2019 (edited) I plan to run my software from a cartridge Not sure I need DOS I created several fixed memory allocations in my code so if I change my starting address I will need to align all the fixed memory accordingly otherwise code will crash I will try setting the starting address to 2048 as suggested above and re align fixed memory accordingly Running from cartridge. So you build a .ROM image in the end, or you build a .xex file that will be loaded by some special binary loader on a cartridge with software capable of loading binary load files (UnoCart etc.)? You need DOS only when your program is reading or writing data to files on the disk. Well technically this can be done even without DOS by direct sector access through services provided by the Atari OS. Edited January 27, 2019 by baktra Quote Link to comment Share on other sites More sharing options...
Yaron Nir Posted January 27, 2019 Author Share Posted January 27, 2019 no need for DOS. By the way the way i've solved it was, i've used the default atari.cfg linker file, i've reduced stack size from 0x800 to 0x400 and it did the trick so now problem is solved 1 Quote Link to comment Share on other sites More sharing options...
sanny Posted January 27, 2019 Share Posted January 27, 2019 By the way the way i've solved it was, i've used the default atari.cfg linker file, i've reduced stack size from 0x800 to 0x400 and it did the trick so now problem is solved Might be good, but keep in mind that stack overflow issues are ones of the most difficult to debug. OTOH, the 0x800 value is quite conservative in the first place. Still depends on your program, though. If you're using many local veriables (or even arrary there), 0x800 might even be small. Look at the linker map file to find out where your memory is consumed. regards, chris 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.