How many register and what kind of register are available for the storage class REGISTER in c langua


Register storage class is used to quicky access the variable and its memory is allocated in CPU. But the registers in the cpu are limited. I use an intel Core i5-4260U Processor. I've visited intel website for the details of the register. But I couldn't find any of such specification of how many registers does the cpu contain (to visit website click <a href="http://ark.intel.com/products/75030/Intel-Core-i5-4260U-Processor-3M-Cache-up-to-2_70-GHz" rel="nofollow">here</a>). Even if i could find that the number of registers((from <a href="https://stackoverflow.com/questions/9130349/how-many-registers-are-there-in-8086-8088" rel="nofollow">How many registers are there in 8086/8088?</a>)) but I couldn't figure out how many of these are used by c storage classes.



But I couldn't find any of such specification of how many registers does the cpu contain


Just look for "ia32 programming model" or "amd64 programming model".


I couldn't figure out how many of these are used by c storage classes.


That is implementation dependent. A compiler can even ignore that. Some of them use automatic register mapping if invoked with a high level of optimization, regardless of the way the variable has been declared.

For example: the programming model for user-mode applications on IA32 is composed of the registers EAX, EBX, ECX, EDX, ESI, EDI, EBP, ESP and EIP. EAX and EDX are used as accumulators, they are implicit operands for some instructions (MUL, DIV) and they hold the return value of a function. EBP and ESP are reserved for stack and frame management. EIP is the instruction pointer. So this leaves us with EBX, ECX, EDI and ESI for register mapping. Depending upon the code generated, one or more of these registers may be needed, so reducing even more the number of available registers for mapping variables.


The <em>register</em> keyword in C was included because when C was created, compilers did not always do a good job of <em>register allocation</em>. Register allocation is the the part of the compiler which maps program variables to CPU registers.

Nowadays, the algorithms compilers use for register allocation are on the whole excellent. So much so that compilers often ignore the <em>register</em> keyword, reasoning that the compiler knows better then the programmer on how to map registers to maximize performance.

I'm not sure what compiler 'mcleod_ideafix' is referring to when he writes that EAX and EDX are not available for register allocation. The <em>gcc</em> compiler uses 6 integer registers in 32 bit x86 code (EAX, EBX, ECX, EDX, ESI, and EDI). It will even use EBP if the function does not make any function calls and you give the proper compiler option. 64 bit mode adds 8 more registers R8 through R15. If you are using <em>gcc</em> just compile your file with the -S option then look at the generated code to see what registers are used.

Another thing to consider is that Intel processors use a feature called <a href="http://en.wikipedia.org/wiki/Register_renaming" rel="nofollow">register renaming</a> to reduce the performance penalty of having not enough registers.


  • Kubernetes 1.8.10 kube-apiserver priorityclasses error
  • Eclipse rendering problems
  • CMake cl.exe is not able to compile a simple test program
  • Compare Dictionary
  • Why does the first run of “XCTestCase -measureBlock:” takes so much time?
  • How can I get the maximum number of OpenMP threads that may be created during the whole execution of
  • Displaying pdf files using the PDFKit interface
  • Why isn't Kubernetes service DNS working?
  • Gforce min not supported for character in data.table
  • Get rendered html code in Backing Component from Composite Component
  • Receive custom intent without activity restart
  • NHibernate proxyexception
  • Can't compile Arduino CapSense example
  • How to call a procedure using NHibernate that returns result from multiple tables?
  • Watson Conversation - Why is the ANYTHING ELSE node not chosen
  • Local Development, Apache vs Developer - file permissions
  • can variables be set randomly when declaring them again?
  • abstracting over a collection
  • Getting media player state in windows phone 7
  • Can't remove headers after they are sent
  • C++ pointer value changes with static_cast
  • Scala multiline string placeholder
  • WPF ICommand CanExecute(): RaiseCanExecuteChanged() or automatic handling via DispatchTimer?
  • How do I get HTML corresponding to current DOM tree?
  • PHP buffered output depending on server setting?
  • How to delay loading a property with linq to sql external mapping?
  • Jenkins: How To Build multiple projects from a TFS repository?
  • Can Jackson SerializationFeature be overridden per field or class?
  • How to show dropdown in excel using jrxml (jasper api)?
  • Redux, normalised entities and lodash merge
  • Android Studio and gradle
  • Trying to get generic when generic is not available
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Java static initializers and reflection
  • Authorize attributes not working in MVC 4
  • Does armcc optimizes non-volatile variables with -O0?
  • Busy indicator not showing up in wpf window [duplicate]
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF