473,395 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Help with memory segments/storage

hello friends,

I recently attended 3 interviews, all three had similar questions...
Where is const stored?
what are diff segments?
what is heap? where is it on RAM/ROM?
what is stored in stack?
what is relation b/w Segments and RAM/ROM/FLASH

Can someone suggest me some tutorial for this?

I have 2 years exp as software developer<embedded application layer>...Have worked on MSP430F1611, ADSP BF531...But due to short project deadlines, I never went into details of all memory segments(which now I regret). I did just normal C coding-compiling application development.. Please can someone guide me with Basics and Guide me to continue furthur in this regard?

+

After Reading few dicussions in this forum, I just opened a .map file using turbo C, (windows xp 32 bit OS/ processor - AMD 64bit, 2800+) can someone explain the below pasted MAP file in brief...also suggest some reference for further reading...

Expand|Select|Wrap|Line Numbers
  1.  Start  Stop   Length Name               Class
  2.  
  3.  00000H 01A66H 01A67H _TEXT              CODE
  4.  01A70H 01EB9H 0044AH _DATA              DATA
  5.  01EBAH 01EBDH 00004H _EMUSEG            DATA
  6.  01EBEH 01EBFH 00002H _CRTSEG            DATA
  7.  01EC0H 01EC1H 00002H _CVTSEG            DATA
  8.  01EC2H 01EC7H 00006H _SCNSEG            DATA
  9.  01EC8H 01F0FH 00048H _BSS               BSS
  10.  01F10H 01F10H 00000H _BSSEND            STACK
  11.  01F10H 01F8FH 00080H _STACK             STACK
  12.  
  13. Detailed map of segments
  14.  
  15. 0000:0000 01FA C=CODE S=_TEXT G=(none) M=C0S ACBP=28
  16. 0000:01FA 0086 C=CODE S=_TEXT G=(none) M=TEST1.C ACBP=28
  17. 0000:0280 003B C=CODE S=_TEXT G=(none) M=IOERROR ACBP=28
  18. 0000:02BB 0030 C=CODE S=_TEXT G=(none) M=EXIT ACBP=28
  19. 0000:02EB 0000 C=CODE S=_TEXT G=(none) M=HEAPLEN ACBP=28
  20. 0000:02EB 00F1 C=CODE S=_TEXT G=(none) M=SETARGV ACBP=28
  21. ..
  22. ..
  23. ..
  24. 01EC:0050 0000 C=BSS S=_BSS G=DGROUP M=GETCH ACBP=48
  25. 01EC:0050 0000 C=BSS S=_BSS G=DGROUP M=CALLOC ACBP=48
  26. 01EC:0050 0000 C=BSS S=_BSS G=DGROUP M=GPTEXT ACBP=48
  27. 01EC:0050 0000 C=BSS S=_BSS G=DGROUP M=MOVETEXT ACBP=48
  28. 01EC:0050 0000 C=BSS S=_BSS G=DGROUP M=PUTCH ACBP=48
  29. 01EC:0050 0000 C=BSS S=_BSS G=DGROUP M=SCROLL ACBP=48
  30. 01EC:0050 0000 C=BSS S=_BSS G=DGROUP M=SCREEN ACBP=48
  31. 01EC:0050 0000 C=BSS S=_BSS G=DGROUP M=VRAM ACBP=48
  32. 01EC:0050 0000 C=BSS S=_BSS G=DGROUP M=WHEREXY ACBP=48
  33. 01F1:0000 0000 C=STACK S=_BSSEND G=DGROUP M=C0S ACBP=28
  34. 01F1:0000 0080 C=STACK S=_STACK G=(none) M=C0S ACBP=74
  35.  
  36.   Address         Publics by Name
  37.  
  38.  0000:01F8       DGROUP@
  39.  01A7:0188       emws_adjust
  40.  01A7:018C       emws_BPsafe
  41.  01A7:0184       emws_control
  42.  01A7:018A       emws_fixSeg
  43.  01A7:016E       emws_initialSP
  44.  01A7:00AE       emws_limitSP
  45.  01A7:017E       emws_nmiVector
  46.  01A7:017A       emws_saveVector
  47.  01A7:018E       emws_stamp
  48.  01A7:0182       emws_status
  49.  01A7:0186       emws_TOS
  50.  01A7:0192       emws_version
  51.  0000:0885       LXMUL@
  52.  0000:01E2       _abort
  53.  0000:0269       _add
  54.  0000:0426       _atexit
  55.  0000:05F6       _brk
  56. .....
  57. .....
  58.  01A7:0458       __atexittbl
  59.  01A7:0498       ___last
  60.  01A7:049A       ___rover
  61.  01A7:049C       ___first
  62.  
  63. Program entry point at 0000:0000
  64.  
  65.  
PS:
I have seen lot of Forums but never have seen better quality discussion in other forums.. Keep it up frds.
Apr 24 '07 #1
1 9636
AdrianH
1,251 Expert 1GB
hello friends,

I recently attended 3 interviews, all three had similar questions...
Where is const stored?
what are diff segments?
what is heap? where is it on RAM/ROM?
what is stored in stack?
what is relation b/w Segments and RAM/ROM/FLASH

Can someone suggest me some tutorial for this?

I have 2 years exp as software developer<embedded application layer>...Have worked on MSP430F1611, ADSP BF531...But due to short project deadlines, I never went into details of all memory segments(which now I regret). I did just normal C coding-compiling application development.. Please can someone guide me with Basics and Guide me to continue furthur in this regard?
I find it quite amazing that you as an embedded developer do not know how the compiler optimises. I would think that it would be required knowledge, esp. on platforms that do not have much in the way of CPU speed and limited resources.

A variable marked const, depending on the compilers optimiser, could be located where you put it (an auto var on the stack in the stack segment, a static var or global var in the data segment) or it could be optimised out of existence, meaning that it is treated as if you had written the number in the places that you used it, sort of like if you used a macro. In that case it would be located all over the text or code segment (different words for basically the same place, though I'm sure that someone may say otherwise).

I've never heard of a diff segment. That doesn't mean it doesn't exist, it just means I've not heard of it. Searching for that on the web didn't bring up anything regarding that either.

Ok, if you don't know what the heap is, what the stack is used for and the location of either of these, just means that you must be doing an assignment, because that is taught in first or maybe second year comp-sci. If you are not a student, then I would really like to know what community collage or university you went to so that I can write them a letter and give them an ear-full as that is disgraceful. They may not tell you what address it is stored in, but they should sure as hell tell you whether it is stored in RAM or ROM.

Flash is a different matter, some courses cover it, others don't. Flash is something like a combination of RAM and ROM. You can write to it under certain circumstances (using a special interface, usually it is hidden behind a library, but it could require that you write to particular memory locations if a library is not available) but is generally acts like ROM and is non-volatile.

Segments are just what they sound like, They segment memory into different parts, so that the programme can use them in different ways. In some architectures, some segments do not overlap and you may not access the memory from one segment though another (i.e. memory in the text segment through the data segment and vice-versa). In other architectures, you may access the same memory in a myriad of different ways by pointing the segment pointers at the right location.

After Reading few dicussions in this forum, I just opened a .map file using turbo C, (windows xp 32 bit OS/ processor - AMD 64bit, 2800+) can someone explain the below pasted MAP file in brief...also suggest some reference for further reading...
As I've not used Turbo C since the 1990's when I was in high school (yeah, I'm dating myself) I don't really know how it is read. However, just looking at it, the first part seems fairly simple. You have the start and stop addresses of a named segment. The addresses start from 0 (the begining of the binary image). As you can see, the stop address is fairly close to the start of the next one.

The next part appears to be the location of the functions, where they are located and it looks like the size of the function.

After that looks to be a less detailed symbol list, and where those symbols are located.

The programme entry point is self explanatory.

PS:
I have seen lot of Forums but never have seen better quality discussion in other forums.. Keep it up frds.
Thanks, we at TSDN try our best.


Adrian
Apr 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Jeremy | last post by:
Hi all, I'm getting very confused about how DB2 uses shared memory and I wonder if someone could clarify matters for me, please ? We are running 32bit DB2 V7.2 FP9 under AIX 4.3.3 on a machine...
4
by: xixi | last post by:
i have a very serious memory problem, we have db2 udb v8.1 load on a HP titanium machine with 4 G memory, it is 64bit machine, currently on DB2 instance , i have three databases, but only one is...
4
by: PaulR | last post by:
Hi, We have a Server running SLES 8 and 3GB memory, with 1 DB2 instance and 2 active Databases. General info... DB2level = "DB2 v8.1.0.72", "s040914", "MI00086", and FixPak "7" uname -a =...
34
by: Andrew | last post by:
Is there anyway to test if a pointer points to allocated memory or not? For example if I have a pointer such as char *p is there a standard way to test whether an assignment such as the following...
8
by: vikram | last post by:
i have series of questions 1.How a c program is loaded in memory i mean the whats is the structure that the code segment?? data segment?? 2.When you say const int *p; where is p...
29
by: keredil | last post by:
Hi, Will the memory allocated by malloc get released when program exits? I guess it will since when the program exits, the OS will free all the memory (global, stack, heap) used by this...
57
by: fermineutron | last post by:
I wrote a program to calculate factorials of large numbers. The long precission integers are stores in arrays. When i specify the length of these arrays larger than 16000 elements, each element is...
7
by: DJP | last post by:
Hi, I had sort of a noob question on memory allocation for strings. char *str1 = "Hello World!"; char str2 = "Hello World!"; In the above bit are both str1 & str2 stack allocated or heap...
26
by: Ravindra.B | last post by:
I have declared a global variable which is array of pointers and allocated memory for each array variable by using malloc. Some thing similar to below... static char *arr; main() { int i;
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.