??? 12/30/04 00:34 Read: times |
#84076 - memory spaces Responding to: ???'s previous message |
Andy Peters said:
You might want to specify what space the array lives in. I think th straight instantiation will put the array on the heap No: the heap is to do with malloc - not something you generally want to find in an embedded system! If you don't explicitly specify the memory space, the compiler will use its default memory space. With Keil, the default memory space is defined by the Memory Model - see the Keil C51 Manual for further details. Andy Peters said:
byte xdata TEST[] = { (byte) 0x01 ... }; If you do that, you will also have to modify the extern declaration in the header file to match: extern byte xdata TEST[]; Andy Peters said:
the compiler will put the array into the external data memory ... To be precise, the compiler will put the array into memory addressed by the MOVX instruction - which may be on-chip or off-chip, depending on what device we're talking about. Andy Peters said:
... if your hardware supports this. (Dunno what'll happen if you don't have hardware support for xdata.) The compiler will do what you tell it. The compiler has no knowledge of your hardware - you must use the appropriate keywords and/or directives applicable to your hardware. If you tell the compiler to put the array in XDATA, it will generate MOVX instructions to access it: if these happen to address non-existent locations in your hardware, you will get undefined results; if these non-existent locations get "reflected" into real addresses, you will get data corruption...! |
Topic | Author | Date |
How to #define an array | 01/01/70 00:00 | |
not an array | 01/01/70 00:00 | |
if you really mean an array | 01/01/70 00:00 | |
Let me clarify myself a bit | 01/01/70 00:00 | |
extern | 01/01/70 00:00 | |
thanks | 01/01/70 00:00 | |
the space is the place ... | 01/01/70 00:00 | |
Answer is wrong - in part | 01/01/70 00:00 | |
you're correct, of course!![]() | 01/01/70 00:00 | |
memory spaces | 01/01/70 00:00 | |
Almost but not quite. | 01/01/70 00:00 | |
being sure | 01/01/70 00:00 | |
oh.. | 01/01/70 00:00 | |
Back to basics | 01/01/70 00:00 |