??? 02/03/05 17:19 Read: times |
#86487 - RAM, ROM, CODE, XDATA Responding to: ???'s previous message |
Neil Kurzman said:
The '51 expects CODE to be in CDATA and RAM to be XDATA. The 8051 knows nothing about RAM or ROM - all it knows is CODE and XDATA. It just knows that it will fetch instructions from CODE space, and can also read data from CODE space using the MOVC instruction. There is no instruction to write to CODE space - so there is generally no point in putting writable memory (RAM) in CODE space. Also, you generally want your code to be non-volatile - so you put it in ROM. Thus ROM is usually fitted in CODE space, but "ROM" and "CODE space" are in no way synonymous. On the other hand, the MOVX instruction can be used to read from XDATA space and write to XDATA space - so generally you will want writable memory (RAM) in XDATA space. Of course, if you only ever read from XDATA (eg, you store only constants in XDATA) you could put a ROM in XDATA space. Thus, again, although RAM is usually fitted in XDATA space, "RAM" and "XDATA space" are in no way synonymous. |