Question9: Which Variable Should be Declared as Registers in a C Program
Answer: Recall that ‘x86-64 bit’ architecture allows up to max of 6 arguments being passed to a procedure to be stored via registers. Register allocation eliminates the need to fetch the arguments from memory thereby reducing the overheads incurred in reading from and writing back to memory. Because of numerous registers available for function parameters, much of the program state is held in registers. Also, some procedures don’t need to access the stack at all.
Since registers eliminate the overheads incurred in reading from and writing back to memory, therefore, a C programmer must declare a variable in register memory which has quite frequent use in the program.
Sanfoundry Global Education & Learning Series – 1000 C Tutorials.
If you wish to look at all C Tutorials, go to C Tutorials.
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Buy Computer Science Books
- Buy C Books
- Apply for C Internship
- Watch Advanced C Programming Videos
- Practice BCA MCQs