User Tools

Site Tools


base:safeguard_against_putting_data_in_wrong_segment

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

base:safeguard_against_putting_data_in_wrong_segment [2017-07-28 18:50] (current)
jupp3 created
Line 1: Line 1:
 +Especially in macros, you often want to put data into a specific segments. After that is done, afaik, there's no way to go back to "previous segment" automatically.
 +The next best thing would be to make current segment "undefined", which isn't possible either.
  
 +One good safeguard for this is to create an empty segment.
 +
 +Add to your config file:
 +<code>
 +MEMORY
 +{
 + EMPTY: start=$07FF,  size=$0000, file=%O;
 + ...
 +}
 +SEGMENTS
 +{
 + EMPTY:             load=EMPTY, type=ro;
 + ...
 +}
 +</code>
 +
 +Then, whenever you want to make sure that developer HAS to define a segment, do:
 +<code>
 +.segment "EMPTY"
 +</code>
 +If you don't:
 +<code>
 +ld65: Warning: config.cfg(4): Memory area overflow in `EMPTY', segment `EMPTY' (1 bytes)
 +ld65: Error: Cannot generate output due to memory area overflow
 +Makefile:62: recipe for target 'example' failed
 +</code>
base/safeguard_against_putting_data_in_wrong_segment.txt ยท Last modified: 2017-07-28 18:50 by jupp3