Microprocessor for overlapping stack frame allocation with saving of subroutine data into stack area
AssigneeMatsushita Electric Industrial Co., Ltd.
InventorsShuichi Takayama, Tetsuya Tanaka
Life of this patent
Estimating the term…
Abstract
When a subroutine call instruction is transferred from the instruction memory 39 to the IDB 29 and decoded by the decoder 18, the following operations (1)-(3) are executed in parallel: (1) a return address storage operation for incrementing the value stored in the PC 15 using the INC 16 and for storing the incremented value in the LR 13 as a return address; (2) a branch operation for storing the entry address of the subroutine included in the subroutine call instruction in the PC 15; and (3) a stack reserve operation for preparing for the following use of a stack area by adding a value “−4” to the value stored in the SP 12 using the adder 22 and for storing the addition result in the SP 12.
Claims48
A microprocessor which is connected to a data memory providing a stack area and to an instruction memory prestoring instructions, comprising:
- a subroutine call means for causing a branch to a subroutine in an execution sequence;
- a stack reserve means for reserving a new stack area in the data memory by updating a stack pointer using a fixed value;
- an instruction fetch means for fetching an instruction from the instruction memory;
- a first instruction execution means for having, when the fetched instruction is a first instruction, the subroutine call means cause the branch and the stack reserve means reserve the new stack area in parallel;
- and
- a post-branch data save means for having, after the branch by the subroutine call means, the stack reserve means reserve another new stack area in parallel with a saving of data into the previously reserved new stack area.
A microprocessor which is connected to a data memory providing a stack area and to an instruction memory prestoring instructions, comprising:
- a program counter for storing an address of a storage area in the instruction memory;
- a stack pointer for storing an address of a storage area in the data memory;
- a subroutine call means for storing an entry address of a subroutine into the program counter;
- a stack reserve means for decrementing the address stored in the stack pointer by one storage area;
- an instruction fetch means for fetching an instruction stored in a storage area specified by the address stored in the program counter from the instruction memory;
- a subroutine call instruction execution means for having, when the fetched instruction is a subroutine call instruction including the entry address, the subroutine call means store the entry address into the program counter and the stack reserve means decrement the address stored in the stack pointer by one storage area in parallel;
- and
- a post-branch data save means for having after the storing of the entry address by the subroutine call means, the stack reserve means decrement the address stored in the stack pointer by one storage area again in parallel with a saving of data into a storage area specified by the previous address in the stack pointer.
A compiler for converting a source program into machine instructions, comprising
- a subroutine call stack reserve instruction generation means for generating a subroutine call stack reserve instruction when a subroutine call instruction is detected in the source program, wherein the subroutine call stack reserve instruction is a machine instruction for having a microprocessor perform the following operations (a) and (b) in parallel,
- (a) a causing of a branch to a subroutine in an execution sequence, and
- (b) a reserving of a new stack area in a data memory;
- and
- a post-branch data save instruction generation means for generating a post-branch data save instruction as an instruction constituting the subroutine, wherein the post-branch data save instruction is a machine instruction for having the microprocessor perform the following operations (c) and (d) in parallel,
- (c) a saving of data, which should be saved, into the new stack area in the data memory, and
- (d) a reserving of another new stack area in the data memory for latter use.
A recording medium for recording machine instruction sequence which is executed by a microprocessor,
- wherein the machine instruction sequence includes a subroutine call stack reserve instruction and a post-branch data save instruction,
- wherein the subroutine call stack reserve instruction is a machine instruction for having the microprocessor perform the following operations (a) and (b) in parallel,
- (a) a causing of a branch to a subroutine in an execution sequence, and
- (b) a reserving of a new stack area in a data memory, and
- the post-branch data save instruction is an instruction constituting the subroutine and a machine instruction for having the microprocessor perform the following operations (c) and (d) in parallel,
- (c) a saving of data, which should be saved, into the new stack area in the data memory, and
- (d) a reserving of another new stack area in the data memory for latter use.
Dependencies are inferred from the claim text.