#29351 - sgeos - Thu Nov 18, 2004 8:31 pm
gcc spits out asm that uses a register "ip". According to this page, ip is "the intra-procedure-call scratch register". What is an "intra-procedure-call scratch register" and what is it used for?
-Brendan
#29352 - DekuTree64 - Thu Nov 18, 2004 9:15 pm
That's just another name for r12. By 'scratch register', they mean it's similar to how you never have to restore r0-r3 to their original values before exiting. The only difference is it will never have an argument or anything in it, so it's just free to do whatever you want with right from the get-go. That also means you need to save it before calling other functions if you have something in it.
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku
#29362 - sgeos - Fri Nov 19, 2004 2:09 am
Fair enough. What is FP and what is it used for?
-Brendan
#29363 - sajiimori - Fri Nov 19, 2004 2:23 am
Is it the frame pointer, which is the backed up copy of the stack pointer before local variables are allocated?
#29365 - DekuTree64 - Fri Nov 19, 2004 2:27 am
That one I've never been too clear on. Since it's called frame pointer, I'd assume that it's used as a frame of reference, maybe to copy the stack pointer into and then push variable numbers of arguments onto it and still be able to access all your variables. That could be done just as well with any register though, so I don't know why they gave it a special name. Maybe just reminiscent of older processors that had special instructions to access specific registers (like the stack instructions in THUMB mode)
_________________
___________
The best optimization is to do nothing at all.
Therefore a fully optimized program doesn't exist.
-Deku
#29368 - tepples - Fri Nov 19, 2004 3:25 am
DekuTree64 wrote: |
Since it's called frame pointer, I'd assume that it's used as a frame of reference, maybe to copy the stack pointer into and then push variable numbers of arguments onto it and still be able to access all your variables. That could be done just as well with any register though, so I don't know why they gave it a special name. |
Defining the frame pointer in the ABI helps debuggers find the frame pointer when they can't infer it from the stack pointer.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#29376 - allenu - Fri Nov 19, 2004 5:49 am
DekuTree64 wrote: |
That one I've never been too clear on. Since it's called frame pointer, I'd assume that it's used as a frame of reference, maybe to copy the stack pointer into and then push variable numbers of arguments onto it and still be able to access all your variables. |
The frame pointer, as I've seen it on other processors, is used to point to the place in the stack where local variables for a function go. You're right that you can use other registers for the same task, but I think often there are opcodes that specifically use the FP register implicitly. That is, you cannot specific another register to use as a 'frame pointer'.
I know on the DSP we use at work, the LINK and UNLINK opcodes automatically adjust FP. Looking through my 68000 book, however, that processor does allow you to specify another register as a frame pointer.