How to understand volatile and non-volatile registers?

Thomson picture Thomson · Aug 14, 2015 · Viewed 7.8k times · Source

CPU registers can be classified as volatile and non-volatile by calling convension, how does does the meaning of word volatile implies the classification?

Answer

Achint picture Achint · Aug 14, 2015

From http://www.techopedia.com/definition/8591/non-volatile-register

Volatile registers' content may change over a subroutine call.

A non-volatile register is a type of register with contents that must be preserved over subroutine calls. Whenever the value of a nonvolatile register is changed by the routine, the old value has to be saved on the stack prior to changing the register and that value has to be restored before returning. A register is similar to a variable, except that there is a fixed number of registers. Every register is a unique location in the CPU in which a single value is saved. A register is the one and only place where mathematical functions, such as addition, multiplication, subtraction, etc., can be carried out. Registers often hold pointers that refer to the memory. Moving values between memory and registers is a common phenomenon.