![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Novell won't pull a SCO - Register | iBot | UNIX and Linux RSS News | 0 | 08-16-2007 02:20 PM |
| Register RSA Key fingerprint with JVM 1.4.2 | asawari | UNIX for Dummies Questions & Answers | 0 | 06-14-2006 03:04 AM |
| Can't register | Not registered | Forum Support Area for Unregistered Users & Account Problems | 2 | 01-27-2006 12:46 PM |
| vi: deleted text not placed in register | maxporter | UNIX for Dummies Questions & Answers | 3 | 01-26-2006 10:34 PM |
| register unsuccessfully | Javier | Forum Support Area for Unregistered Users & Account Problems | 1 | 02-18-2005 03:04 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Register variables
Hi
Is there any limit on the number of register variables can be used at any one time? Does this limit depends on the number registers that the CPU holds? In a large program is it wise to declare all the loop counter as register variables? Thanx Andonis Matsakas |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
The register keyword is just a hint to the compiler. There is no limit on how many times you can use that hint. There is also no guarantee that any of the variables will wind up with a somewhat dedicated register.
The register keyword is largely obsolete and I would not recommend using it for new code. Today's optimizers are very good at allocating registers where they are do the most good. And, by the way, today's risc and post-risc cpu's tend to have lots of registers to allocate. Registers aren't the scarce resource that they were in the 70's. |
|
#3
|
|||
|
|||
|
When to use register variables?
Hi,
I never clearly understood when to use the keyword "register", I just know that it is a request to the system to provide space for this object in the CPU registers, which are faster in accessing than RAM. Can anyone provide me a small practical situation where it becomes imperative to use the keyword "register"? I would also appreciate if someone suggests me a good book which emphasizes the use of registers. I have searched the forums and found this thread Register variables but it didn't answer my question - in which situations do we use them? I have seen industry strength C programs written by experts, which chose certain variables to be registers while declaring others as normal types, but couldn't quite appreciate why certain variable need to be a register. Thank you! Vishnu. |
|
#4
|
||||
|
||||
|
No one can give you an example where it is imperative to use the register keyword. It is never imperative. It never was. It never will be.
An example of where is might be useful is something like: Code:
register int i;
register int tot;
int table[1000];
tot=0;
for(i=0; i<1000; i++)
tot += table[i];
But to make the above code actually useful, you must compile it with a very old compiler. Modern compilers will figure this out by themselves. And you really need to be an assembler programmer to fully grasp this. You need to understand what a register is. And that machine language instructions move data between registers and memory. So the books to read are those on assembly language programming. Mastering assembler should clear this right up. |
||||
| Google The UNIX and Linux Forums |