How to see the memory occupied by an initialized array versus an uninitialized array
I am currently learning assembly programming by following Kip Irvine "Assembly Language for the x86 Processor". In section 3.4.12, the author states:
The directive
.DATA?
declares uninitialized data. When defining a large block of uninitialized data, the directive.DATA?
reduces the size of the compiled program. For example, the following code is effectively declared:
.data smallArray DWORD 10 DUP(0) ; 40 bytes .data? bigArray DWORD 5000 DUP(?) ; 20,000 bytes, not initialized
The following code, on the other hand, creates a compiled program of 20,000 bytes more:
.data smallArray DWORD 10 DUP(0) ; 40 bytes bigArray DWORD 5000 DUP(?) ; 20,000 bytes
I want to see the memory size of each version of the code after the program is compiled, so I can see the effect .DATA?
for myself, but I'm not sure how this can be done.
source to share
I want to see the memory size of each version of the code after compiling the program ...
The difference lies in the size of the compiled executable, not the size of its image in memory when it is executed.
In short: most modern operating systems have the ability for an executable file to declare a memory area "zero full". The executable only has to say how big the region is, so it is much smaller than if it included a bunch of literal zeros for that region.
source to share