Results 1 to 8 of 8

Thread: Which one is faster - memory or registers

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    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
    Baaaaaaaaah

  2. #2
    Addicted Member hypnos's Avatar
    Join Date
    Aug 2000
    Location
    UK
    Posts
    183
    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.

  3. #3
    amac
    Guest
    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)

  4. #4
    Megatron
    Guest
    The downside is that they are limited, so you should only store your most fequently used variables in the them.

  5. #5
    Hyperactive Member Radames's Avatar
    Join Date
    Feb 2001
    Location
    Tech Tropics
    Posts
    360
    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

  6. #6
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    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."

  7. #7

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    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
    Baaaaaaaaah

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    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
  •  



Click Here to Expand Forum to Full Width