Re: [cc65] BSS Segment

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-08-25 18:46:28


On Mon, Aug 25, 2003 at 12:26:17PM -0400, Chris Sebrell wrote:
> I'm working on an 80-Column display library (assembler/CA65) for the Apple II and I'm
> wondering what the .BSS segment is really used for.  The docs just say that ".BSS"
> directive "switches to the BSS segment."  Is this un-initialized data?  I vaguely recall
> this segment name from my way-back-when x86 days.

Yes, bss is uninitialized data. If you're using just the assembler, and don't
plan to make romable code, you can ignore it.

> Right now I'm just using ".CODE" and ".DATA"

For simplicity, you could also just use code. However, the rules I'm using for
my own code (and for cc65 code) are:

    STARTUP, LOWCODE, CODE
    Contains just code, no data, and is not writable. That does especially mean
    no self modifying code. This means that CODE can go into a ROM.

    RODATA
    Read only data, which is not modified.

    LOWDATA, DATA
    Initialized data that is modified by the program. By definition, pieces of
    self modyfing code go here or into BSS.

    BSS
    Uninitialized data. BSS segments are allocated in memory but there is no
    data in the output file for these segments, which saves space on the disk.
    The startup code for C language programs will zero all BSS segments, which
    means that any variable will have a value of zero on startup.

    ZEROPAGE
    This is like BSS, but located in the zeropage.

Having read only CODE and RODATA segments is important for ROMable code, and
sometimes for debugging: The VICE emulator for example is able to write
protect memory regions using a watchpoint feature. Assuming that you have one
of those ugly memory overwrite error, it sometimes helps to write protect all
segments that do contain read only code and data and then wait until the
program tries an illegal write operation.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2003-08-25 18:46:39 CEST