Merit of callee-saved register



Hi,

I've a general question about calling conventions and the use of registers
across calls. In a book I found this:
"For a variable whose range of appearance spans many procedure calls,
the use of a callee-saved register is advantageous, because saving and
restoring once at the procedure entry and exit respectively are cheaper
than saving and restoring around each call."

What I don't understand is the term "cheaper". In my opinion cheaper must
mean less code (i.e. less instructions in the code) since when the same
function is invoked multiple times, there are just once the instructions
in this function for saving/restoring while in the case of register
saving/restoring around the each call for each call separate instructions
must be added.

Cheaper cannot mean faster execution because the number of executed
saving/restoring instructions would be the same for both approaches,
right?

Or do you understand this in another way?

Regards,
Tim
.



Relevant Pages

  • Merits of callee-saved registers
    ... What I don't understand is the term "cheaper". ... there are just once the instructions ... in this function for saving/restoring while in the case of register ... saving/restoring around the each call for each call separate instructions ...
    (comp.programming)
  • Re: Optimization Questions
    ... cycles you'd save would be more than offset by the cycles you'd burn ... instructions go through port 0 and port 1. ... a 16-bit register, writing one afterwards will be fast. ... Pre-read the value in EAX ...
    (comp.lang.asm.x86)
  • Re: Learning ARM assembler...
    ... the newer ARM instructions, you can largely ignore them if you prefer. ... programmers also develop habits that help to avoid non-orthogonality (for ... that you can't use another register for the same purpose). ... instructions have a more compact encoding when used in this way, ...
    (comp.sys.acorn.programmer)
  • Re: Learning ARM assembler...
    ... the sum of a displacement plus a register plus a second register shifted ... instruction encoding standpoint. ... instructions have a more compact encoding when used in this way, ...
    (comp.sys.acorn.programmer)
  • Re: Kind of new: function implementation questions, MASM
    ... >sub esp, varsize ... >select which of the local variables to copy into the working register, ... If you have 512kB of 8-way associative cache, ... You probably shouldn't use the prefetch instructions at all. ...
    (comp.lang.asm.x86)