Pointers ?


What Are Pointers…

Pointer is an address, or a numeric index which is assigned to each unit of memory in the system. It can refers directly to (or "points to") another value stored elsewhere in the computer memory using its address.

Why Pointers

  1. Improve performance for repetitive operations.
  2. pointers effectively take the place of general purpose registers.
  3. Allow both protected and unprotected access to memory addresses.
  4. much cheaper in time and space complexity.

Where Are They Used

  1. traversing strings, lookup tables, control tables and tree structures.
  2. data structures like lists, queues, trees and stack
  3. to hold the addresses of functions. pointers to functions often using virtual method tables

How To Solve Pointers

precedance

Pointers can be solved by referring above table.

() having highest and return type or data type having lowest priority

a 

Pointer To Function

b

More On Pointer

Tiny” Code and data will be in the same segment (especially, the registers CS,DS,ES,SS will point to the same segment); “near” pointers are always used. Code, data and stack together cannot exceed 64K.
Small” Code and data will be in different segments, and “near” pointers are always used. There will be 64K of space for code and 64K for data/stack.
Medium” Code pointers will use “far” pointers, enabling access to 1MB. Data pointers remain to be of the “near” type. “Compact” Data pointers will use “far” and code will use “near” pointers.
Large”/“Huge” Code and data pointers will be “far”
vpspace

 

Addressing Modes

For 16 Bit

Addressing modes for 16-bit

For 32 Bit

Addressing modes for 32

For 64 Bit

Addressing modes for 64

 

Terms

  • Referencing a pointer pointing to memory location.
  • Dereferencing a pointer obtaining the value at the location a pointer refers.
  • Absolute Pointer actual physical address or a virtual address.
  • Relative pointer an offset from base address resolved by arithmetic operation.
  • Null Pointer indicating that it refers to no object.
  • Wild pointers are pointers that have not been initialized.
  • auto_ptr (C++0x unique_ptr) ensures that the object to which it points gets destroyed automatically when control leaves a scope.
  • hazard pointer is an element used by a method that allows the memory allocated to the nodes of lock-free dynamic shared objects to be reclaimed (HT).
  • opaque pointer is a special case of opaque data type, a data type that is declared to be a pointer to data structure of some unspecified type.
  • bounded pointer is a pointer that is augmented with additional information that enable the storage bounds within which it may point to be deduced
  • Smart pointers typically keep track of the objects they point to for the purpose of memory management such as automatic garbage collection or bounds checking.
  • segmentation fault beyond the range of available memory.
  • 64 bit AMD64 where pointers are 64 bit long and addresses only extend to 48 bits, 64 GB physical address range.
  • 32 bit x86 where pointers are 32 bits long and addresses only extend to 36 bit ,4 GB of physical address range.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s