Re: [cc65] BSS Segment

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2003-08-25 19:59:22


On Mon, Aug 25, 2003 at 01:53:55PM -0400, shubel, paul wrote:
> True.  But why do all compiler runtimes set it to zero (like it is required
> that it be explicitly initialized to zero)?

The C standard requires that uninitialized variables contain data as if the
assignment

        variable = 0

had been executed before main() is called. Contrary to popular belief, that
does NOT mean an initialization with binary zero. For example

        double f;

must be initialized by a 0.0, even if the bit pattern for 0.0 is not all bits
zero (which is true for some machines). The NULL pointer is also something
that must not consist of a value that contains all zero bits (even if it does
on all platforms).

Fortunately, for cc65 NULL pointers and ints with the value zero do always
have all bits zero, so the bss segment may be cleared by just writing binary
zeroes into it.

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 19:59:33 CEST