Page 1 of 1

CA65 ReadOnlySegments

Posted: Mon Jul 27, 2015 10:47 am
by beamrider
HI

I'm a bit confused about what marking either memory or segments as RO (type = ro) is doing in the CA65 .cfg file.. The documentation is a little lacking and just says that it marks the segment as read-only, but what exactly does that mean in practice?

There's nothing stopping you from writing to a read-only segment at runtime?

Adrian

Re: CA65 ReadOnlySegments

Posted: Mon Jul 27, 2015 11:12 am
by Mike
They're mainly there to designate a memory range for const strings and init data for static variables of C in cc65.

Of course a pure assembly program can't be stopped from writing to a RO-Segment, but holding symbols of C there allows for static checks.

@mods: That being said, this thread should be moved to the 'Emulators & Cross-Development' section. Thanks.

Re: CA65 ReadOnlySegments

Posted: Mon Jul 27, 2015 11:45 am
by groepaz
its not very relevant unless you are writing code that goes to ROM (like a cartridge) - then you can put the rodata section into rom.

for handwritten assembler programs that will be loaded into RAM, dont bother and use .code and .data only (if even that) :)

Re: CA65 ReadOnlySegments

Posted: Mon Jul 27, 2015 1:12 pm
by beamrider
Thanks, for the replies.

After RTFM I found that RAM areas marked as "Read Only" can only contain segments also marked as "Read only", so it's just a function of the linker and not applicable at runtime at all as you both say.

I did find a good use for it before though by putting all the code and static data into Read Only segments and loading this into VICE as detailed here