US5261101A
Expired / Lapsed
US
⏱️ 0.0 years remaining
Method for calling and returning from subroutine that is invoked by either a near call or a far call
Assignee: Microsoft Technology Licensing LLC
•
Filing: 1990-02-28
•
Granted: 1993-11-09
•
Expires: 2010-02-28
Abstract
Abstract A method for calling and returning from a computer subroutine is provided. The method allows a subroutine executing on a stack-oriented computer with segmented addressing, such as the Intel 80386, to be invoked by both an inter-segment call and an intra-segment call instruction. The method allows multiple subroutines in one code segment to share an inter-segment return instruction. The method further provides for the locating of that instruction so that the pushing of its offset onto the stack can be accomplished efficiently.
Inventors
- 👤 Thomas Fenwick
Bibliographic Details
Application Number
—
Jurisdiction
US
Data Source
google_patents
Last Synchronized
2026-10-25 04:32
CPC Classifications
G; G06; G06F; G06F9/00; G06F9/06; G06F9/44; G06F9/448; G06F9/4482; G06F9/4484; G06F9/4486
Claims Analysis
Total Claims: 21
Claim 1
Independent Claim
246 words
A method for invoking and returning from a subroutine on a computer having code segments, an instruction set, and an instruction pointer, the instruction set having a near call instruction for intra-code segment invoking of the subroutine, a near return instruction for intra-code segment returning from the subroutine, a far call instruction for inter-code segment invoking of the subroutine, and a far return instruction for inter-code segment returning from the subroutine, the subroutine comprising a plurality of instructions from the instruction set being stored in a code segment, the subroutine having a far entry point, each code segment having a plurality of locations for storing instructions, each location within a code segment having an associated offset within the code segment, the method comprising the steps of: executing the far call instruction specifying the far entry point of the subroutine to be executed; when executing the subroutine in response to executing the far call instruction specifying the far entry point, storing the offset of a location containing the far return instruction that is located in the code segment in which the subroutine is stored, the offset being less than 128 or greater than 65,407; executing the near return instruction to retrieve the location of the stored offset and to set the instruction pointer to point to the location of the stored offset; and executing the far return instruction pointed to by the instruction pointer to effect a return to an instruction following the executed far call instruction.
Claim 2
Independent Claim
246 words
A method for invoking and returning from a subroutine on a computer having code segments, an instruction set, and an instruction pointer, the instruction set having a near call instruction for intra-code segment invoking of the subroutine, a near return instruction for intra-code segment returning from the subroutine, a far call instruction for inter-code segment invoking of the subroutine, and a far return instruction for inter-code segment returning from the subroutine, the subroutine comprising a plurality of instructions from the instruction set being stored in a code segment, the subroutine having a far entry point, each code segment having a plurality of locations for storing instructions, each location within a code segment having an associated offset within the code segment, the method comprising the steps of: executing the far call instruction specifying the far entry point of the subroutine to be executed; when executing the subroutine in response to executing the far call instruction specifying the far entry point, storing the offset of a location containing the far return instruction that is located in the code segment in which the subroutine is stored, the offset being less than 128 or greater than 65,407; executing the near return instruction to retrieve the location of the stored offset and to set the instruction pointer to point to the location of the stored offset; and executing the far return instruction pointed to by the instruction pointer to effect a return to an instruction following the executed far call instruction.
Claim 3
Dependent Claim
61 words
The method of claim 1 wherein the computer is based on the architecture of the Intel 8086-family of microprocessors, the computer having a stack and a push instruction, the push instruction comprising an operation code and immediate data, and wherein the step of storing the offset includes the step of executing the push instruction to push the offset onto the stack.
Claim 4
Dependent Claim
29 words
The method of claim 2 wherein the step of executing the push instruction includes the steps of retrieving a one-byte operation code and retrieving one byte of immediate data.
Claim 5
Dependent Claim
27 words
The method of claim 3 wherein the step of retrieving one byte of immediate data includes the step of retrieving one byte containing a value of zero.
Claim 6
Dependent Claim
33 words
The method of claim 1 including the step of executing an instruction located at a near entry point of the subroutine that is located at an offset immediately after the far entry point.
Claim 7
Dependent Claim
27 words
The method of claim 1 wherein the step of storing the offset includes the step of executing a push instruction to push the offset onto a stack.
Claim 8
Dependent Claim
20 words
The method of claim 1 wherein the step of storing the offset includes the step of storing a zero value.
Claim 9
Independent Claim
293 words
A method for computer subroutine linkage on a computer having a stack, a push instruction, code segments, memory locations identified by segmented addresses comprising a segment portion and an offset portion, and a near call instruction for intra-code segment subroutine invoking, a near return instruction for intra-code segment subroutine returning, a far call instruction for inter-code segment subroutine invoking, and a far return instruction for inter-code segment subroutine returning, the computer having a subroutine, the subroutine having a near entry point, the subroutine located in a code segment, the method comprising the steps of: storing the push instruction in the memory location before the near entry point of the subroutine, the stored push instruction to push the offset of a memory location containing the far return instruction onto the stack; storing the far return instruction in a memory location with an offset less than 128 or greater than 65,407 in the code segment in which the subroutine is located; and storing the near return instruction in a memory location within the subroutine whereby when the subroutine is invoked using the far call instruction a far return address is pushed onto the stack and control is transferred to the memory location containing the stored push instruction, when the stored push instruction is executed the offset of the stored far return instruction is pushed onto the stack, when the stored near return instruction is executed the offset pushed by the executed push instruction is popped from the stack and control is transferred to the stored far return instruction at the popped offset, and when the stored far return instruction is executed the far return address pushed by the far call instruction is popped from the stack and control is transferred to the far return address.
Claim 10
Independent Claim
293 words
A method for computer subroutine linkage on a computer having a stack, a push instruction, code segments, memory locations identified by segmented addresses comprising a segment portion and an offset portion, and a near call instruction for intra-code segment subroutine invoking, a near return instruction for intra-code segment subroutine returning, a far call instruction for inter-code segment subroutine invoking, and a far return instruction for inter-code segment subroutine returning, the computer having a subroutine, the subroutine having a near entry point, the subroutine located in a code segment, the method comprising the steps of: storing the push instruction in the memory location before the near entry point of the subroutine, the stored push instruction to push the offset of a memory location containing the far return instruction onto the stack; storing the far return instruction in a memory location with an offset less than 128 or greater than 65,407 in the code segment in which the subroutine is located; and storing the near return instruction in a memory location within the subroutine whereby when the subroutine is invoked using the far call instruction a far return address is pushed onto the stack and control is transferred to the memory location containing the stored push instruction, when the stored push instruction is executed the offset of the stored far return instruction is pushed onto the stack, when the stored near return instruction is executed the offset pushed by the executed push instruction is popped from the stack and control is transferred to the stored far return instruction at the popped offset, and when the stored far return instruction is executed the far return address pushed by the far call instruction is popped from the stack and control is transferred to the far return address.
Claim 11
Dependent Claim
22 words
The method of claim 8 wherein the step of storing the far return instruction stores the far return instruction at offset zero.
Claim 12
Independent Claim
245 words
A method of modifying a computer subroutine designed to execute on a computer having a near call instruction for intra-code segment subroutine invoking, a near return instruction for intra-code segment subroutine returning, a far call instruction for inter-code segment subroutine invoking, a far return instruction for inter-code segment subroutine returning, and a push instruction, the computer having a stack, code segments, and segmented addresses, the segmented addresses comprising a code segment number and an offset, the subroutine having a near entry point designed to be invoked by the near call instruction, the subroutine located in a code segment, the method comprising the steps of: storing in the code segment in which the subroutine is located at an offset less than 128 or greater than 65,407 the far return instruction; and storing in the code segment in which the subroutine is located at a far entry point the push instruction to push onto the stack the offset of the stored far return instruction such that the near entry point is entered after the push instruction is executed, whereby when the subroutine is invoked using the far call instruction through the far entry point the stored push instruction stores the offset of the stored far return instruction onto the stack and when the subroutine returns using the near return instruction the near return instruction retrieves the offset of the stored far return instruction and transfers control to the stored far return instruction to return from the subroutine.
Claim 13
Independent Claim
245 words
A method of modifying a computer subroutine designed to execute on a computer having a near call instruction for intra-code segment subroutine invoking, a near return instruction for intra-code segment subroutine returning, a far call instruction for inter-code segment subroutine invoking, a far return instruction for inter-code segment subroutine returning, and a push instruction, the computer having a stack, code segments, and segmented addresses, the segmented addresses comprising a code segment number and an offset, the subroutine having a near entry point designed to be invoked by the near call instruction, the subroutine located in a code segment, the method comprising the steps of: storing in the code segment in which the subroutine is located at an offset less than 128 or greater than 65,407 the far return instruction; and storing in the code segment in which the subroutine is located at a far entry point the push instruction to push onto the stack the offset of the stored far return instruction such that the near entry point is entered after the push instruction is executed, whereby when the subroutine is invoked using the far call instruction through the far entry point the stored push instruction stores the offset of the stored far return instruction onto the stack and when the subroutine returns using the near return instruction the near return instruction retrieves the offset of the stored far return instruction and transfers control to the stored far return instruction to return from the subroutine.
Claim 14
Dependent Claim
23 words
The method of claim 10 wherein the step of storing the stored far return instruction stores the far return instruction at offset zero.
Claim 15
Independent Claim
230 words
A method in a computer system of invoking and returning from a subroutine, the computer system having code segments and an instruction set having instructions, each code segment having memory locations, each memory location for storing an instruction and having an offset within the code segment, the instruction set having a near call instruction for intra-code segment invocations of the subroutine, a near return instruction for returning from intra-code segment invocations of the subroutine, a far call instruction for inter-code segment invocations of the subroutine, and a far return instruction for returning from inter-code segment invocations of the subroutine, the subroutine having a plurality of instructions stored within memory locations of a designated code segment, one of the memory locations of the subroutine being a far entry point, the method comprising the steps of: executing the far call instruction to invoke the subroutine through the far entry point; and executing the subroutine, wherein the step of executing the subroutine includes the steps of: storing the offset of a predefined memory location within the designated code segment containing the far return instruction, executing the near return instruction to retrieve the stored offset of the predefined memory location and to transfer execution control to the retrieved offset; and executing the far return instruction contained in the memory location at the retrieved offset within the designated code segment to return from the subroutine.
Claim 16
Independent Claim
230 words
A method in a computer system of invoking and returning from a subroutine, the computer system having code segments and an instruction set having instructions, each code segment having memory locations, each memory location for storing an instruction and having an offset within the code segment, the instruction set having a near call instruction for intra-code segment invocations of the subroutine, a near return instruction for returning from intra-code segment invocations of the subroutine, a far call instruction for inter-code segment invocations of the subroutine, and a far return instruction for returning from inter-code segment invocations of the subroutine, the subroutine having a plurality of instructions stored within memory locations of a designated code segment, one of the memory locations of the subroutine being a far entry point, the method comprising the steps of: executing the far call instruction to invoke the subroutine through the far entry point; and executing the subroutine, wherein the step of executing the subroutine includes the steps of: storing the offset of a predefined memory location within the designated code segment containing the far return instruction, executing the near return instruction to retrieve the stored offset of the predefined memory location and to transfer execution control to the retrieved offset; and executing the far return instruction contained in the memory location at the retrieved offset within the designated code segment to return from the subroutine.
Claim 17
Dependent Claim
41 words
The method of claim 12 including the steps of storing another subroutine within the designated code segment and during execution of the other subroutine, executing the far return instruction contained in the predefined memory location to return from the other subroutine.
Claim 18
Dependent Claim
22 words
The method of claim 12 wherein the step of storing the offset includes the step of storing an offset less than 128.
Claim 19
Dependent Claim
22 words
The method of claim 12 wherein the step of storing the offset includes the step of storing an offset greater than 65,407.
Claim 20
Dependent Claim
44 words
The method of claim 12 wherein the instruction set includes an instruction for storing immediate data contained within the instruction and wherein the step of storing the offset of the predefined memory location includes the step of executing the instruction for storing immediate data.
Claim 21
Dependent Claim
32 words
The method of claim 16 wherein the step of executing the instruction for storing immediate data includes the step of storing a zero value as the offset of the predefined memory location.
References Cited (Backward Citations)
US4944578A
Cited
USPTO Annuity & Maintenance Windows
| Annuity Stage | Window Opens | Payment Deadline | Surcharge Period Until | Estimated Fee | Status |
|---|---|---|---|---|---|
| 3.5 Years (Year 4) | 1996-11-08 | 1997-05-10 | 1997-11-09 | $2000.00 | Window Closed / Lapsed |
| 7.5 Years (Year 8) | 2000-11-08 | 2001-05-10 | 2001-11-09 | $3760.00 | Window Closed / Lapsed |
| 11.5 Years (Year 12) | 2004-11-08 | 2005-05-10 | 2005-11-09 | $7700.00 | Window Closed / Lapsed |