0% found this document useful (0 votes)
9 views3 pages

Week 10 - 1. Memory Types and Models, Pointers, Pointer's Memory Type

The document discusses memory types and models in the 8051 microcontroller, detailing various memory types such as code, data, and xdata, along with their specifications. It also explains pointers, including typed and untyped pointers, and their usage in C programming for the 8051. Additionally, it provides examples of pointer declarations and their memory types.

Uploaded by

naveen g c
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Week 10 - 1. Memory Types and Models, Pointers, Pointer's Memory Type

The document discusses memory types and models in the 8051 microcontroller, detailing various memory types such as code, data, and xdata, along with their specifications. It also explains pointers, including typed and untyped pointers, and their usage in C programming for the 8051. Additionally, it provides examples of pointer declarations and their memory types.

Uploaded by

naveen g c
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

EMBEDDED C PROGRAMMING 20EC43P 2022-23

Week 10 - 1. Memory types and models, pointers, pointer’s memory type.

10.1.1 Memory Types and Memory Models


10.1.1.1 Memory Types
The 8051 has various types of memory space including internal and external code and data
memory. Thus, when variables are declared we should know in which type of memory they reside.
For this purpose, several memory type specifiers such as code, data, idata, bdata, xdata & pdata are used.
Memory type Description
code Code memory (64Kbytes)
data Direct addressable internal data memory 128 bytes
bdata Bit addressable internal data memory 16 bytes
xdata External data memory 64k bytes
idata Indirectly addressable internal data memory (256 bytes)
pdata Paged external data memory (256a bytes)

Example:
1. unsigned int data count ; variable count resides in the internal data memory
2. bit bdata num ; variable num resides in bit addressable locations of internal data memory

10.1.1.2 Memory models


Memory models are used to reside all declared variables in a default memory type. Once memory
model is defined all variables are assigned to corresponding memory type and it is not necessary to explicitly
specify memory type for all variables.
Memory model Description
Small Variables default to internal data memory (data)
Compact Variables default to the first 256 bytes of external data memory (pdata)
large Variables default to external data memory (xdata)

10.1.2 Pointers
In 8051 assembly language registers R0, R1 and DPTR are used as memory pointers. These registers
are used to hold the address of the memory location where the data is stored.
In 8051 C indirect addressing can be done through pointer variables. Pointer variable is a type of
variable in which it holds the address of the data.
Electronics and Communication Engg. Page 1
EMBEDDED C PROGRAMMING 20EC43P 2022-23

Declaration syntax:
data type * pointer variable name;
Eg:
1. int *p; //Here * is used to indicate a pointer variable
2. int n;
int *p=&n; // initialization the symbol ampersand ‘&’ refers to ‘address of. The p is a pointer //
variable which holds the address of n

10.1.3 Types of pointers


There are 2 types of pointers namely
1. Typed pointers
2. Untyped Pointers

10.1.3.1 Typed pointers


Typed pointers are the one through which we can specify the memory area where pointer is stored and also
specify the memory area where the data pointed by the pointer is stored.

Eg: int data * xdata P = &n;

Internal data memory external data memory

 The above statement declares a pointer variable ‘P’ to reside in external data memory (xdata) and this
pointer points to data of type int that itself stored in the variable n in internal data memory (data)
 The memory type specifier data, before * specifies the “data memory type” while
 The data memory type specifier ‘xdata’ after * specifies the pointer memory type
 Thus, pointer declaration where data memory types are explicitly specified are called typed pointers

10.1.3.2 Untyped pointers


Untyped pointers are another kind of pointers in which the data memory type is not mentioned explicitly
when declaring pointers.

Eg: int * xdata P=&n;

data type external data memory


Electronics and Communication Engg. Page 2
EMBEDDED C PROGRAMMING 20EC43P 2022-23

 Here it does not explicitly specify the memory type of data pointed by the pointers. The pointers can
point to the data residing in any type of memory.
 Untyped pointers have the advantage that, they can be used to point to any data in dependent of the type
of memory in which the data is stored.

REFERENCES
[1] Scott MacKenzie and Raphael C.W. Phan. The 8051 Microcontroller. (4/e), Pearson education, 2008.
[2] Kenneth J Ayala, The 8051 Microcontroller, (3/e), Thomson Delmar Learning.

Electronics and Communication Engg. Page 3

You might also like