This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

8052 data memory 128bytes or 256 byte?

Hello,
i am using 8052 in my project and according to datasheet the data memory is 256 bytes but in my code if i exceed 128 bytes the code is not compiled

do i need to use it as x data memory?

please help

Parents
  • Thanks Neil for your quick response

    but i sincerely feels, that when compiler is aware of that there are two sections of ram available with the selected microcontroller ( 8052) why the hell is it need to be informed to keep extra varilable in in the extended memory

    No doubt the access will be solwer in this case of access made to the extended 128 bytes that the first 128 bytes.

    but compiler should offer us an option of keep in variable in extended memory without using the "idata" in front of every variable

    I understand the questions asked by me was stupid becaues in assembely language we are ware of using it with the help of @r0 or @r1 but i was really confused and surprised that i really have to mention the "idata" for such variables and compiler is simply dormant for this overflow

    why the hell compiler cannot use idata memomery itself?

Reply
  • Thanks Neil for your quick response

    but i sincerely feels, that when compiler is aware of that there are two sections of ram available with the selected microcontroller ( 8052) why the hell is it need to be informed to keep extra varilable in in the extended memory

    No doubt the access will be solwer in this case of access made to the extended 128 bytes that the first 128 bytes.

    but compiler should offer us an option of keep in variable in extended memory without using the "idata" in front of every variable

    I understand the questions asked by me was stupid becaues in assembely language we are ware of using it with the help of @r0 or @r1 but i was really confused and surprised that i really have to mention the "idata" for such variables and compiler is simply dormant for this overflow

    why the hell compiler cannot use idata memomery itself?

Children
  • How do propose that the compiler should decide which variables to put into DATA and which into IDATA??

  • If the compiler automatically allocated variables to idata and data, the first feature demanded would be a way to control which variable went into which memory space. I can see the post now -- "Why doesn't Keil add some keywords so I can force a variable into a particular memory space?"

    The two memory spaces have distinctly different access methods, with different overhead in both code space and time. If variables moved back and forth at the whim of the compiler, your program would constantly be changing size and timing for no apparent reason. Certainly, a good program wouldn't depend on that sort of behavior. On the other hand, it would be one of those hassles you don't need while staying up late trying to work out a bug.

    Data space is a precious commodity that often needs to be carefully allocated. A really smart compiler might be able to work out all the tradeoffs between frequency of access, speed of access, code size, and so on. But that involves understand very high level semantics of the program. As a programmer, I'd certaily want a way to override any such judgements when I disagree with the way the optimizer optimizes.

    It might be a nice luxury to have a "don't care" memory address space assignment keyword, so the compiler could put it in data, idata, or xdata at its whim.

    U8 data oftenAccessed;
    U8 any whoCares;

  • Perhaps a 4th Memory Model that defaults everything to IDATA?

    (Neither Raisonance nor Tasking seems to offer such a model, but IAR does).

  • but i sincerely feels, that when compiler is aware of that there are two sections of ram available with the selected microcontroller ( 8052) why the hell is it need to be informed to keep extra varilable in in the extended memory

    Translation: "is it reasonable to require me to think?"

    Erik

  • Hello Eric,

    I dont understand your translation, can you elaborate a bit?

    Thanks and Regards

  • "I dont understand your translation, can you elaborate a bit?"

    Although using 'C' relieves you of having to think about a lot of the detail that assembler programming requires, it does not (and cannot) relieve you of all thinking.

    The compiler can do all the "mechanical" things, but it can't do the things that require real intelligence and original thought - you still have to do that yourself.

    Deciding which variables to put into DATA and which into IDATA is one such thing.

  • Using your real/artificial intelligence and original thoughts answer this.

    Why do have and option for memory model small, medium or Large ?

    Whatever is your intelligent answer !

    Using your "original thoughts" pls think about data and idata.

    If we need real/artificial intelligence and original thoughts to use idata like

    unsigned char idata variable;

    why cannot we extend our real/artificial intelligence and original thoughts for xdata or pdata

    like

    unsigned char pdata variable;
    unsigned char xdata variable;

    I think only people with real/artificial intelligence and original thoughts can answer this stupid question

    may be there should be two versions of compiler

    one with real/artificial intelligence, with all such nonsense options, for dumb people
    without original thoughts, like me.

    one with no intelligence, with no such nonsense options, for people with high real/artificial intelligence and original thoughts, Like........

    I apologize troubling your real/artificial intelligence and original thoughts.

  • one with real/artificial intelligence, with all such nonsense options, for dumb people

    Careful what you wish for. At the point where you just tell the compiler what you want the program to do, software development jobs will have moved to the minimum wage sector.

  • Be carefull!

    This can be answered and understood by the peopel with Real/artificial intelligence and original thoughts like.......

  • How about answering the original question:

    How do you propose that the compiler should decide which variables to put into DATA and which into IDATA??

  • Why do have and option for memory model small, medium or Large ?
    because the '51 ain't no PC

    why cannot we extend our real/artificial intelligence and original thoughts for xdata or pdata
    because the '51 ain't no PC

    may be there should be two versions of compiler
    impossible because the '51 ain't no PC

    If you want to program "like for a PC" program a friggin PC, do not try to press your PC philosophy on the '51 because the '51 ain't no PC

    Erik

    There is a school of thought states tha "C is C there is no need to know the underlying architecture"

    Ok there also are things like horsefeathers

  • kapil singhi wondered:
    "Why do have and option for memory model small, medium or Large ?"

    Erik replied:
    "because the '51 ain't no PC"

    Actually, PC Development tools do have a similar "memory model" concept!

    Anyhow, I think the OP's point was not "why do we have memory models at all?" but rather "why do we have only those 3 memory models" and, in particular, why isn't there a memory model that uses IDATA?

    As I've alreay noted, only one of the four "big" commercial compilers seems to provide an additional IDATA memory model - the other three (which includes Keil) all have just Small (DATA), Medium (PDATA), and Large (XDATA).

    Must be something in that...?

  • As I've alreay noted, only one of the four "big" commercial compilers seems to provide an additional IDATA memory model - the other three (which includes Keil) all have just Small (DATA), Medium (PDATA), and Large (XDATA).

    an example I have not seen ANY "power user" in this forum that does not deride malloc() and the associated when used on the '51, I am sure RK is included although not officially. Nevertheless the Keil '51 tools do support it.

    This lead me to the following conclusion:
    to claim adherence and to pacify (sell to) the "C is C" users the '51 tool makers have included features they know are ridiculous when applied to the '51 architecture.

    The "IDATA memory model" probably is the result of a complaint from someone like the op in this thread complaining "why do I have to install external memory when I have more than 128 and less than 256 variables, I can, of course, not be bothered with qualifying storage"

    Erik

  • "an example I have not seen ANY "power user" in this forum that does not deride malloc() and the associated when used on the '51,"

    I use malloc occasionally depending on the application. What's you're problem with it?

  • Because the size of RAM in an embedded system is almost always fixed & known at compile time (especially on systems suited to an 8051), there is seldom any point in dynamic allocation.
    But it always adds an overhead - and the question of what to do if a malloc call fails...!