Did DOS zero out the BSS area when it loaded a program?How did the Sideways address space work?When did 64K...

How do I ask for 2-3 days per week remote work in a job interview?

How to prevent criminal gangs from making/buying guns?

How can I shoot a bow using Strength instead of Dexterity?

How would armour (and combat) change if the fighter didn't need to actually wear it?

How to not forget things?

How do figure out how powerful I am, when my abilities far exceed my knowledge?

How much can I judge a company based on a phone screening?

What are the odds of rolling specific ability score totals in D&D?

Can anybody tell me who this Pokemon is?

Suspension compromise for urban use

Match 4 columns and replace 1 in 2 files

Sum Square Difference, which way is more Pythonic?

Least cost swapping in C++

Lípínguapua dopo Pêpê

Is this bar slide trick shown on Cheers real or a visual effect?

Locked room poison mystery!

What unique challenges/limitations will I face if I start a career as a pilot at 45 years old?

Did Pope Urban II issue the papal bull "terra nullius" in 1095?

What's the relationship betweeen MS-DOS and XENIX?

Is the Microsoft recommendation to use C# properties applicable to game development?

How do I call a 6-digit Australian phone number with a US-based mobile phone?

Scam? Phone call from "Department of Social Security" asking me to call back

Bringing Power Supplies on Plane?

Illustrator - SVG make thinner path



Did DOS zero out the BSS area when it loaded a program?


How did the Sideways address space work?When did 64K RAM become about as cheap as 16K?When did CPUs start using page mode DRAM?Can the BBC Master co-processor execute a program in the I/O processor's memory?Why did C have the return type before functions?How did DOS know where to load itself in upper memory?Why did the TI-99/4 have two databuses?How did the ZX80 store both a useful program and screen memory?Why did C use the -> operator instead of reusing the . operator?How did early x86 BIOS programmers manage to program full blown TUIs given very few bytes of ROM/EPROM?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







24















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 held the memory 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?










share|improve this question




















  • 8





    I don't know if DOS did it or not, but if it didn't, the C runtime would have almost certainly ensured that uninitialized global and static data zeroed as required by the language (or else lots of programs would not have worked).

    – Erik Eidt
    yesterday











  • I would have guessed it didn't, purely because GO.COM existed.

    – grawity
    3 hours ago


















24















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 held the memory 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?










share|improve this question




















  • 8





    I don't know if DOS did it or not, but if it didn't, the C runtime would have almost certainly ensured that uninitialized global and static data zeroed as required by the language (or else lots of programs would not have worked).

    – Erik Eidt
    yesterday











  • I would have guessed it didn't, purely because GO.COM existed.

    – grawity
    3 hours ago














24












24








24


1






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 held the memory 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?










share|improve this question














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 held the memory 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?







memory memory-layout c dos






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked yesterday









smitellismitelli

5923 silver badges10 bronze badges




5923 silver badges10 bronze badges











  • 8





    I don't know if DOS did it or not, but if it didn't, the C runtime would have almost certainly ensured that uninitialized global and static data zeroed as required by the language (or else lots of programs would not have worked).

    – Erik Eidt
    yesterday











  • I would have guessed it didn't, purely because GO.COM existed.

    – grawity
    3 hours ago














  • 8





    I don't know if DOS did it or not, but if it didn't, the C runtime would have almost certainly ensured that uninitialized global and static data zeroed as required by the language (or else lots of programs would not have worked).

    – Erik Eidt
    yesterday











  • I would have guessed it didn't, purely because GO.COM existed.

    – grawity
    3 hours ago








8




8





I don't know if DOS did it or not, but if it didn't, the C runtime would have almost certainly ensured that uninitialized global and static data zeroed as required by the language (or else lots of programs would not have worked).

– Erik Eidt
yesterday





I don't know if DOS did it or not, but if it didn't, the C runtime would have almost certainly ensured that uninitialized global and static data zeroed as required by the language (or else lots of programs would not have worked).

– Erik Eidt
yesterday













I would have guessed it didn't, purely because GO.COM existed.

– grawity
3 hours ago





I would have guessed it didn't, purely because GO.COM existed.

– grawity
3 hours ago










1 Answer
1






active

oldest

votes


















42














No, it didn't. MS-DOS never bothered to zero out allocated memory, as there was no security reason to do so like there is in a multi-user operating system. It was up to the C runtime startup code to zero out the BSS segment.



For example, from the Borland C++ 3.1 startup code:



;       Reset uninitialized data area

xor ax, ax
mov es, cs:DGROUP@@
mov di, offset DGROUP: bdata@
mov cx, offset DGROUP: edata@
sub cx, di
cld
rep stosb




_BSS            SEGMENT
bdata@ label byte
ENDS

_BSSEND SEGMENT
edata@ label byte
ENDS





share|improve this answer























  • 7





    And the source code for DOS’s exec routine is now available (for version 2.0), which shows how BSS is allocated but not zeroed (see also the memory management routines elsewhere).

    – Stephen Kitt
    yesterday






  • 1





    The "no security reason because it was a single-user system" argument was indeed how it was thought about in those days. It doesn't really work in today's world -- smartphones are definitely single-user systems, as are (in practice) most laptops, but security is a paramount cocern there even so. What saved MS-DOS (and yet not really!) was that most of the systems were not networked, or if they were then only with a few other machines in the same office.

    – Henning Makholm
    4 hours ago
















Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "648"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f12027%2fdid-dos-zero-out-the-bss-area-when-it-loaded-a-program%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









42














No, it didn't. MS-DOS never bothered to zero out allocated memory, as there was no security reason to do so like there is in a multi-user operating system. It was up to the C runtime startup code to zero out the BSS segment.



For example, from the Borland C++ 3.1 startup code:



;       Reset uninitialized data area

xor ax, ax
mov es, cs:DGROUP@@
mov di, offset DGROUP: bdata@
mov cx, offset DGROUP: edata@
sub cx, di
cld
rep stosb




_BSS            SEGMENT
bdata@ label byte
ENDS

_BSSEND SEGMENT
edata@ label byte
ENDS





share|improve this answer























  • 7





    And the source code for DOS’s exec routine is now available (for version 2.0), which shows how BSS is allocated but not zeroed (see also the memory management routines elsewhere).

    – Stephen Kitt
    yesterday






  • 1





    The "no security reason because it was a single-user system" argument was indeed how it was thought about in those days. It doesn't really work in today's world -- smartphones are definitely single-user systems, as are (in practice) most laptops, but security is a paramount cocern there even so. What saved MS-DOS (and yet not really!) was that most of the systems were not networked, or if they were then only with a few other machines in the same office.

    – Henning Makholm
    4 hours ago


















42














No, it didn't. MS-DOS never bothered to zero out allocated memory, as there was no security reason to do so like there is in a multi-user operating system. It was up to the C runtime startup code to zero out the BSS segment.



For example, from the Borland C++ 3.1 startup code:



;       Reset uninitialized data area

xor ax, ax
mov es, cs:DGROUP@@
mov di, offset DGROUP: bdata@
mov cx, offset DGROUP: edata@
sub cx, di
cld
rep stosb




_BSS            SEGMENT
bdata@ label byte
ENDS

_BSSEND SEGMENT
edata@ label byte
ENDS





share|improve this answer























  • 7





    And the source code for DOS’s exec routine is now available (for version 2.0), which shows how BSS is allocated but not zeroed (see also the memory management routines elsewhere).

    – Stephen Kitt
    yesterday






  • 1





    The "no security reason because it was a single-user system" argument was indeed how it was thought about in those days. It doesn't really work in today's world -- smartphones are definitely single-user systems, as are (in practice) most laptops, but security is a paramount cocern there even so. What saved MS-DOS (and yet not really!) was that most of the systems were not networked, or if they were then only with a few other machines in the same office.

    – Henning Makholm
    4 hours ago
















42












42








42







No, it didn't. MS-DOS never bothered to zero out allocated memory, as there was no security reason to do so like there is in a multi-user operating system. It was up to the C runtime startup code to zero out the BSS segment.



For example, from the Borland C++ 3.1 startup code:



;       Reset uninitialized data area

xor ax, ax
mov es, cs:DGROUP@@
mov di, offset DGROUP: bdata@
mov cx, offset DGROUP: edata@
sub cx, di
cld
rep stosb




_BSS            SEGMENT
bdata@ label byte
ENDS

_BSSEND SEGMENT
edata@ label byte
ENDS





share|improve this answer















No, it didn't. MS-DOS never bothered to zero out allocated memory, as there was no security reason to do so like there is in a multi-user operating system. It was up to the C runtime startup code to zero out the BSS segment.



For example, from the Borland C++ 3.1 startup code:



;       Reset uninitialized data area

xor ax, ax
mov es, cs:DGROUP@@
mov di, offset DGROUP: bdata@
mov cx, offset DGROUP: edata@
sub cx, di
cld
rep stosb




_BSS            SEGMENT
bdata@ label byte
ENDS

_BSSEND SEGMENT
edata@ label byte
ENDS






share|improve this answer














share|improve this answer



share|improve this answer








edited yesterday

























answered yesterday









Ross RidgeRoss Ridge

5,5863 gold badges21 silver badges31 bronze badges




5,5863 gold badges21 silver badges31 bronze badges











  • 7





    And the source code for DOS’s exec routine is now available (for version 2.0), which shows how BSS is allocated but not zeroed (see also the memory management routines elsewhere).

    – Stephen Kitt
    yesterday






  • 1





    The "no security reason because it was a single-user system" argument was indeed how it was thought about in those days. It doesn't really work in today's world -- smartphones are definitely single-user systems, as are (in practice) most laptops, but security is a paramount cocern there even so. What saved MS-DOS (and yet not really!) was that most of the systems were not networked, or if they were then only with a few other machines in the same office.

    – Henning Makholm
    4 hours ago
















  • 7





    And the source code for DOS’s exec routine is now available (for version 2.0), which shows how BSS is allocated but not zeroed (see also the memory management routines elsewhere).

    – Stephen Kitt
    yesterday






  • 1





    The "no security reason because it was a single-user system" argument was indeed how it was thought about in those days. It doesn't really work in today's world -- smartphones are definitely single-user systems, as are (in practice) most laptops, but security is a paramount cocern there even so. What saved MS-DOS (and yet not really!) was that most of the systems were not networked, or if they were then only with a few other machines in the same office.

    – Henning Makholm
    4 hours ago










7




7





And the source code for DOS’s exec routine is now available (for version 2.0), which shows how BSS is allocated but not zeroed (see also the memory management routines elsewhere).

– Stephen Kitt
yesterday





And the source code for DOS’s exec routine is now available (for version 2.0), which shows how BSS is allocated but not zeroed (see also the memory management routines elsewhere).

– Stephen Kitt
yesterday




1




1





The "no security reason because it was a single-user system" argument was indeed how it was thought about in those days. It doesn't really work in today's world -- smartphones are definitely single-user systems, as are (in practice) most laptops, but security is a paramount cocern there even so. What saved MS-DOS (and yet not really!) was that most of the systems were not networked, or if they were then only with a few other machines in the same office.

– Henning Makholm
4 hours ago







The "no security reason because it was a single-user system" argument was indeed how it was thought about in those days. It doesn't really work in today's world -- smartphones are definitely single-user systems, as are (in practice) most laptops, but security is a paramount cocern there even so. What saved MS-DOS (and yet not really!) was that most of the systems were not networked, or if they were then only with a few other machines in the same office.

– Henning Makholm
4 hours ago




















draft saved

draft discarded




















































Thanks for contributing an answer to Retrocomputing Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fretrocomputing.stackexchange.com%2fquestions%2f12027%2fdid-dos-zero-out-the-bss-area-when-it-loaded-a-program%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...