Thread: Why registers?

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2011
    Posts
    4
    Rep Power
    0

    Why registers?


    Hi,
    i am a newcomer to OS....

    Why do we need registers for storing function parameters when the primary memory already has the parameters?
    For eg:

    Code:
    int sum(int a, int b) {}
    the values a and b are already available in the primary memory, then why should the general purpose register store them?

    Or is it that the CPU fetches the data from primary memory and puts them in the registers and then executes them?
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    Getting a value out of a register is like you getting milk out of your refrigerator, while getting a value out of memory is like you going to the store to buy a new carton of milk. You get the milk either way, but one method is a lot faster.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo