![]() ![]() This is not easy stuff but it will give you a great inside in how C++ works and interacts with different platforms. If you really want to go deeper in to C++, I'd advise on learning how a compiler works and who it goes from a high level (C++) to a platform independent code to a low level code (assembler) and finally to executable binary. I have a degree in Computer Architecture and organization, I had to refresh my memory too but this is all stuff I had to learn and even implement by building my own CPU. The major difference between Stack memory and heap memory is that the stack is used to store the order of method execution and local variables while the heap. I don't know if it's the same with people here. ![]() Many of which effects the way memory is used by the CPU but the basic ARC layout can still be found in one form or an other.Īs for this not being popular, having worked as a programmer I was surprised at how many programmers I worked with don't know this stuff. The data segment is for global variables and. The heap is for multipurpose storage (like dynamic allocation (malloc etc)) while stack is used specifically for instruction pointer and for storing your variables when you call another procedure (like during recursion). There are many new technologies and features that have been introduced since then, like 64bit, pipe-lining, multi-band memory, north/south bridges, and so on. The entire memory is organized into 4 segments. Keep in mind this is based on a ARC CPU build somewhere in the 90's. The stack and heap layout are standard to all CPU's, the other parts like I/O and graphics can differ from CPU to CPU. But for the more basic stuff its always good to know, but no must. It is important in more advanced programming situations, like programming drivers or interfacing with hardware, or a must if you are doing assembler and low level languages. I think I am misreading these illustrations. The stack is specifically employed for static memory allocation, while the heap serves as the field of dynamic memory allocation. ![]() Some of the illustrations from the Web show stack memory 'above' heap memory. However, now I am confused as to how stack memory can be below heap memory and decrease addresses, while heap is above stack memory and increases addresses. So the two types of memory are presumably working as they are supposed to. The address of the first element of ch1, the second stack array, is 0012FF34. The address of the first element of ch0, the first stack array, is 0012FF48. The address of the first element of chb, the second heap array, is 00345A90. The address of the first element of cha, the first heap array, is 00345A48. I am guessing that means stack memory addresses will have smaller numbers than heap memory addresses, as my output shows.įor ( int i = 0 i (cha) (chb) (&ch0) (&ch1) << endl The illustration in my book of the memory layout shows stack memory 'below' heap memory. The addresses of the other elements increase by 1 unit in both arrays. The output I get is an address of 00345A48 for the first element of the ch (heap) array, and an address of 0012FF48 for the first element of the ch0 (stack) array. #include "././std_lib_facilities.h" int main ()įor ( int i = 0 i (ch) (&ch0) << endl ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |