Chinaunix首页 | 论坛 | 博客
  • 博客访问: 130856
  • 博文数量: 38
  • 博客积分: 2091
  • 博客等级: 大尉
  • 技术积分: 390
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-03 06:18
文章分类

全部博文(38)

文章存档

2012年(1)

2011年(36)

2010年(1)

我的朋友

分类: 网络与安全

2011-05-26 16:18:19

8051 和 x86 在内存结构方面很大不同。
  • 8051:内存分为物理上独立的若干区域(Memeory Areas/Spaces)。
  • x86:  内存连续编址,数据、程序放在同一个连续的地址空间

在Keil C中声明变量,可以使用存储类型标识符(memory type specifier)来说明变量的存储的内存区域,以此提高代码执行效率。存储标识符包括: code, data, idata, xdata, pdata, etc.

注意区分:变量的数据类型(Data Type)存储类型(Memory Type)


8051 Memory Areas
Program Memory
Program (CODE) memory is read only; it cannot be written to. Program memory may reside within the 8051 MCU, it may be external, or it may be both, depending upon the 8051 derivative and the hardware design.
  • The 8051 architecture supports up to 64K Bytes of program memory. However, program space can be expanded using code banking.
  • Some devices offer a larger code space.
  • Program code, including all functions and library routines, is stored in program memory.
  • Constant variables may also be stored in program memory.
  • The 8051 executes programs stored in program memory only.
  • Program memory may be accessed from your C programs using the code memory type specifier.

Note

  • Program memory may be accessed indirectly using the instruction. It may not be accessed directly.

Internal Data Memory

Internal data memory resides within the 8051 MCU and is read/write. Up to 256 bytes of internal data memory are available depending upon the 8051 derivative. The first 128 bytes of internal data memory (from 0x00 to ox7F) are both directly and indirectly addressable. The upper 128 bytes of data memory (from 0x80 to 0xFF) can be addressed only indirectly (this address space, when accessed directly, is mapped to SFRs). There is also a 16 byte area starting at 20h that is bit-addressable. (NOTE: The upper 128 bytes of data memory and SFR are DIFFERENT! Although both are marked with same address numbers, 0x80 ~ 0xFF)

Access to internal data memory is very fast because it can be accessed using an 8-bit address. However, internal data memory is limited to a maximum of 256 bytes.

Internal data can be broken down into three distinct memory types: data, idata, and bdata.

  • The data memory specifier always refers to the first 128 bytes of internal data memory. Variables stored here are accessed using direct addressing.
  • The idata memory specifier refers to all 256 bytes of internal data memory; however, this memory type specifier code is generated by indirect addressing which is slower than direct addressing.
  • The bdata memory specifier refers to the 16 bytes of bit-addressable memory in the internal data area (20h to 2Fh). This memory type specifier allows you to declare data types that may also be accessed at the bit level.

External Data Memory

External data memory is read/write. Since external data memory is indirectly accessed through a data pointer register (which must be loaded with an address), it is slower than access to internal data memory.

Several 8051 devices provide on-chip XRAM space that is accessed with the same instructions as the traditional external data space. This XRAM space is typically enabled via dedicated chip configuration SFR registers and overlaps the external memory space.

There may be up to 64K Bytes of external data memory; though, this address space does not necessarily have to be used as memory. Your hardware design may map peripheral devices into the memory space. If this is the case, your program would access external data memory to program and control the peripheral. This technique is referred to as memory-mapped I/O.

The C51 Compiler offers two memory types that access external data: xdata and pdata.

  • The xdata memory specifier refers to any location in the 64K Byte address space of external data memory. The locates variables in this memory space.
  • The pdata memory type specifier refers to exactly one (1) page (256 bytes) of external data memory. The locates variables in this memory space.

Note

  • External data memory may be accessed indirectly using the instruction. It may not be accessed directly.

REFERENCE
*) Memory Areas,
*) http://blog.csdn.net/sky0829/archive/2010/11/08/5995093.aspx

阅读(3368) | 评论(0) | 转发(0) |
0

上一篇:8051 特殊功能寄存器 (SFR)

下一篇:Shell case

给主人留下些什么吧!~~