Implementation of Elementary Data Types:"

Implementation of Elementary data type consists of

• Storage representation for data objects

• Values of that type

• Set of algorithms or procedures that define the operations of the type in terms of manipulations of the storage representation.

Storage representation of Elementary data type:

1) Hardware Influence: Computer hardware influence the storage of elementary data type.

In this case computer hardware executes the program. If the hardware storage representation are used, then the basic operations on data of that data type not implemented using hardware provided operations.

2) Software influenced: If we do not use hardware storage representation, then the operation must be software simulated and some operation will execute much less efficient.

Two methods to treat Attributes:

It has to be determined by the compiler and not stored in discriptors during execution or not stored in runtime storage representation. It is usually a method in C language.

It is stored in a descriptor as part of the data object at runtime in LISP, Prolog language .

The storage representation is usually described in terms of

• Size of the block of memory required(the number of memory words bytes, ot bits needed)

• Layout of attributes and data values within the block.

Implementation of operations:

Each operation defined for data objects of a given type may be implemented in one of three main ways:-

1) Directly as a hardware operation: If simple data types are stored using the hardware representation, when the primitive operations are implemented using the arithmetic operations built in to hardware.

2) As a Subprogram or procedure: A square root for an example, this operation is not provided directly as a hardware operation. So it is software simulated implemented as a procedure or function.

3) as an inline code sequence: It is software implementation of the code and its operation. Instead of using a subprogram, operation in the subprogram are copied into the program at the point where the subprogram would otherwise have been invoked.

For Example:

The absolute value of function on numbers

abs(x)= if x<0 then -x else x

is usually implemented as an inline code sequence.

a) fetch value of x from memory

b) if x >0, skip the next instruction

c) set x=-x

d) store new value of x in memory

Here each line is implemented by a single hardware operation.

12- Implementation of Elementary Data Type- Programming Languages


Facebook Likes