By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,712 Members | 1,591 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,712 IT Pros & Developers. It's quick & easy.

Help with memory segments/storage

P: 1
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
Share this Question
Share on Google+
1 Reply


AdrianH
Expert 100+
P: 1,251
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

Post your reply

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