Ques : What is Register Variables

, , No Comments

Besides three storage class specifications namely, Automatic, External and Static, there is a register storage class. Registers are special storage areas within a computer’s CPU. All the arithmetic and logical operations are carried out with these registers.

For the same program, the execution time can be reduced if certain values can be
stored in registers rather than memory. These programs are smaller in size (as few
instructions are required) and few data transfers are required. The reduction is there in
machine code and not in source code. They are declared by the proceeding declaration
by register reserved word as follows:

register int m;

Points to remember:

• These variables are stored in registers of computers. If the registers are not
available they are put in memory.
• Usually 2 or 3 register variables are there in the program.
• Scope is same as automatic variable, local to a function in which they are
declared.
• Address operator ‘&’ cannot be applied to a register variable.
• If the register is not available the variable is though to be like the automatic
variable.
• Usually associated integer variable but with other types it is allowed having
same size (short or unsigned).
• Can be formal arguments in functions.
• Pointers to register variables are not allowed.
• These variables can be used for loop indices also to increase efficiency.

0 टिप्पणियाँ:

Post a Comment