As an example, say we have a DOS MZ EXE file that's around 20 KiB in size. The EXE header contains the value 0x1400
at offset 0x0A
indicating that the program is requesting 5,120 paragraphs (or 80 KiB) to be allocated in addition to the space occupied by the load image. When the load is complete, a total of 100 KiB will be available for the program's direct use.
I don't know what the "official" term was for the 80 KiB allocation in this example, but I know it as BSS from the *nix world.
My question is simply, did DOS zero out this area when it loaded the program, or could there be garbage inside it from whatever the memory held previously? If DOS did not zero it out, was it something that most programs (or the runtimes they were compiled/linked with) did on their own?
I'm mainly interested in the perspective from a typical C program of the day. If I understand it correctly, C guarantees that all static variables without an explicit initializer get set to 0
, and those variables seem to end up being stored in the BSS area. So whose job was it to ensure they were properly zeroed?