|
-
Aug 1st, 2001, 01:01 AM
#1
Thread Starter
PowerPoster
Which one is faster - memory or registers
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
-
Aug 1st, 2001, 09:29 AM
#2
Addicted Member
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.
-
Aug 1st, 2001, 11:25 AM
#3
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)
-
Aug 1st, 2001, 12:10 PM
#4
The downside is that they are limited, so you should only store your most fequently used variables in the them.
-
Aug 3rd, 2001, 02:06 AM
#5
Hyperactive Member
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.
Top Tip: You can make friends and impress the opposite sex at geeky cocktail parties by saying "DB" instead of database. - Karl Moore
-
Aug 3rd, 2001, 03:11 AM
#6
Frenzied Member
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.
Harry.
"From one thing, know ten thousand things."
-
Aug 3rd, 2001, 06:35 PM
#7
Thread Starter
PowerPoster
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
-
Aug 4th, 2001, 01:35 AM
#8
Monday Morning Lunatic
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.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|