Jump to content

Photo

CC65 - Segment `BSS' overflows memory area `MAIN' by 67 bytes


9 replies to this topic

#1 Yaron Nir OFFLINE  

Yaron Nir

    Star Raider

  • 98 posts

Posted Sat Jan 26, 2019 3:50 PM

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



#2 baktra OFFLINE  

baktra

    Dragonstomper

  • 606 posts
  • Location:Czech republic

Posted Sat Jan 26, 2019 4:03 PM

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.

#3 Yaron Nir OFFLINE  

Yaron Nir

    Star Raider

  • Topic Starter
  • 98 posts

Posted Sat Jan 26, 2019 4:23 PM

playing a bit with the starting address solved this , but i fear going forward i will need to carefully plan the memory.

 

cheers



#4 baktra OFFLINE  

baktra

    Dragonstomper

  • 606 posts
  • Location:Czech republic

Posted Sun Jan 27, 2019 5:19 AM

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.

#5 damosan OFFLINE  

damosan

    Space Invader

  • 17 posts

Posted Sun Jan 27, 2019 8:14 AM

... 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?



#6 baktra OFFLINE  

baktra

    Dragonstomper

  • 606 posts
  • Location:Czech republic

Posted Sun Jan 27, 2019 8:32 AM

 

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.



#7 Yaron Nir OFFLINE  

Yaron Nir

    Star Raider

  • Topic Starter
  • 98 posts

Posted Sun Jan 27, 2019 12:57 PM

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

#8 baktra OFFLINE  

baktra

    Dragonstomper

  • 606 posts
  • Location:Czech republic

Posted Sun Jan 27, 2019 1:16 PM

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 by baktra, Sun Jan 27, 2019 1:17 PM.


#9 Yaron Nir OFFLINE  

Yaron Nir

    Star Raider

  • Topic Starter
  • 98 posts

Posted Sun Jan 27, 2019 2:17 PM

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



#10 sanny OFFLINE  

sanny

    Moonsweeper

  • 358 posts
  • Location:Bavaria

Posted Sun Jan 27, 2019 3:21 PM

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






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users