Just wanted to that is memory faster than CPU registers if you want store and get large variable.
I am thinking of using inline assembly in my C\C++ appz for a faster program:p
Printable View
Just wanted to that is memory faster than CPU registers if you want store and get large variable.
I am thinking of using inline assembly in my C\C++ appz for a faster program:p
Yep, registers are a lot faster. Lets not forget, registers are right inside your CPU. That means your CPU doesn't have to go through the motherboards bus to access them, as it does when accessing the memory.
I just wanted to jump on the band wagon and tell you that registers are faster...
I'd think the registers are the fastest type of memory in your system... after that would have to be tag RAM (something like that), cache, RAM (normal), ROM, and then some type mass storage (HDD)
The downside is that they are limited, so you should only store your most fequently used variables in the them.
Indeed, registers are faster. BUT...The compiler chooses if the variable will be stored there. Depends on the lenght of the program and the times that value is used.
Some compilers choose to ignore what you want to do (*cough* VC++ *cough*) and it can be a struggle getting them to do things like inline and register things when you want them to. You can't always make things stay in the registers of course.
I am just curious about the registers that why does not it effect the os or any other program using the registers when you change the registers
It does affect the OS, but what it does is...when it transfers execution to another thread (the scheduling) it saves the state of the processor, swaps in the next thread's info, runs the thread, pauses it again, saves the latest, swaps back another thread's info, and runs...
And so on :) Maybe that's not quite what it does but you see what I mean :)
Check out setjmp and longjmp for info on things like this...however...DON'T use them in C++ programs because they mess up constructor/destructor calls because they're very low level.