Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
22 years ago

difference caller/callee saved register

Hi,

I have beginner question:

why altera is calling register r8-r15 "caller-saved general-purpose registers", and r16-r23 "callee-saved general-purpose registers".

I think it's because caller (callee) have to save these registers before (after) the call occured. Is that true?

thanks for your help,

Sylvain

1 Reply

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    The hardware treats the registers in exactly the same way.

    The difference is in the treatment by the compiler. A caller saved register can be corrupted (have its value changed) by a function call, wheras a callee saved register is guaranteed to have the same value after the function call.

    If you call a compiled function then there is no need to save "caller saved" registers, you just need to be aware that their value after the function call won't always be the same as before it.