Mike Rosing wrote:
>On Mon, 28 Feb 2005, wadsworth_bob wrote:
>
>>I am using the SHARC 21065 processor. At the end of
some of the code
>>I have inherited, the following code exists:
>>
>>_exit:
>> i12=dm(m7,i6);
>> jump (m14,i12) (db);
>> rframe;
>> nop;
>>.ENDSEG;
>>
>>Can anyone tell me what this is for?
>>
>>
>
>The manual says the following:
>
>CJUMP |function | (PC, <reladdr24>) | (DB);
>RFRAME;
>
>Function:
>The CJUMP instruction is generated by the C compiler
for function calls,
>and is not intended for use in assembly language
programs. CJUMP combines
>a direct or PC-relative jump with register
transfer
operations that save
>the frame and stack pointers. The RFRAME
instruction
reversed the
>register transfers to restore the frame and
stack
pointers.
>
>...
>
>instruction what it does
>
>CJUMP function(DB) JUMP function (DB),
R2=I6, I6=I7;
>
>RFRAME; I7 = I6, I6 = DM(0,I6)
>
>So it looks like you do a look up into a table, then
jump to some offset
>from that address, and fix the registers i6 and
i7
along the way. It's
>from a C compiler, so you may want to find the
original source code to
>figure out what is really going on.
>
>Patience, persistence, truth,
>Dr. mike
>
>
This is the "exit" macro used to maintain the run-time
stack on return
from a function call. I7 is the stack pointer and I6
is the frame
pointer. The frame pointer points to the bottom of the
current functions
stack and the stack pointer points to the top where
the free space is.
The bottom of the current functions stack always
contains the previous
functions frame pointer.
In the first instruction i6 contains the previous
functions frame
pointer and m7 contains the offset required to access
the return address
from the function, should be -1. The second
instruction jumps to the
return address + 1, as the return address is pointing
to the second
instruction of the delayed branch of the original
function call, so m14
should contain a modifier of 1.
The RFRAME instruction makes the stack pointer equal
to the frame
pointer. This releases the memory used for the current
functions stack.
As mentioned I6 points to the previous functions frame
pointer. Thus the
second part of the RFRAME instruction modifies the
frame pointer. So
the stack and frame pointers are now set up for the
original calling
function.
Send instant messages to your online friends http://uk.messenger.yahoo.com
|