Apparatus for executing a plurality of program segments having different object code types in a single program or processor environment
First Claim
1. A method for executing a plurality of modes in a program or processor environment in a computer system having at least one central processing unit and a memory, said method comprising the steps of:
- allocating memory space for a routine descriptor;
setting a pointer to the address of the routine descriptor, setting contents of a first field in the routine descriptor equal to a nonvalid instruction, the field being positioned in the routine descriptor such that the pointer to the routine descriptor points to the contents of the field;
executing contents of the field;
switching from a first mode to a second mode when executing contents of the field which are equal to a nonvalid instruction; and
after further processing returning to the first mode.
0 Assignments
0 Petitions
Accused Products
Abstract
The invention provides a method and apparatus for switching between execution of a plurality of object code types having different conventions for invoking program procedures and performing stack manipulations. The invention may also be used to switch between different calling conventions within a single object code type. Briefly according to the invention, a computer system comprises a routine descriptor, a stack switch frame, a mode switching mechanism for switching from a first processor, code or calling convention type to a second processor, code or calling convention type and means for executing instructions in various code types.
A routine descriptor describes a program or code segment and its code type and calling conventions. A routine descriptor contains, among other information, a “mixed mode” field which is set to a specific, predetermined value such as a value indicating an instruction which is not legal in the runtime environment of a first processor, code or calling convention type. When that instruction is encountered, control is transferred to the mode switching mechanism. A routine descriptor also contains a “procedure information” field which is set to a value indicating the convention for invoking a program segment and performing appropriate stack manipulations.
When a routine calls a routine having a different stack model, the mode switching mechanism uses a stack switch frame to provide a transition between the two different stack types.
-
Citations
6 Claims
-
1. A method for executing a plurality of modes in a program or processor environment in a computer system having at least one central processing unit and a memory, said method comprising the steps of:
-
allocating memory space for a routine descriptor;
setting a pointer to the address of the routine descriptor, setting contents of a first field in the routine descriptor equal to a nonvalid instruction, the field being positioned in the routine descriptor such that the pointer to the routine descriptor points to the contents of the field;
executing contents of the field;
switching from a first mode to a second mode when executing contents of the field which are equal to a nonvalid instruction; and
after further processing returning to the first mode. - View Dependent Claims (2)
setting contents of a procedure pointer field in the routine descriptor to the address of the routine being described by the routine descriptor; and
after switching to the second mode, executing the routine addressed by the procedure pointer field.
-
-
3. A method for executing a plurality of modes to a processor environment in a computer system having at least one central processing unit and a memory, said method comprising the steps of:
-
allocating memory space for a routine descriptor;
setting a pointer to the address of the first routine descriptor;
setting contents of a mixed mode field in the first routine descriptor equal to a specific predetermined instruction;
executing contents of the field;
switching from a first mode to a second mode when executing contents of the mixed mode field which are equal to a nonvalid instruction;
setting contents of a selector field in the first routine descriptor to a type of mode switching operation to be performed after switching to the second mode;
after switching to the second mode, performing the operation indicated by the contents of the selector field;
allocating a second routine descriptor;
setting the selector field in the second routine descriptor to a value indicating a return to the first mode operation;
allocating a stack switch frame;
saving values of registers in the stack switch frame;
determining if the routine being described by the first routine descriptor is register-based or stack-based and if the routine is register-based, moving input parameters from first mode registers and putting them into second mode registers;
putting information into the stack switch frame;
if the routine returns a value, allocating space in the stack switch frame for it;
putting paramters into the stack switch frame;
setting a return address in the stack switch frame equal to the address of the second routine descriptor;
executing the routine described by the first routine descriptor;
checking the selector field of the second routine descriptor; and
when the selector field of the second routine descriptor indicates a return operation, returning to the first mode.
-
-
4. An article of manufacture for use in a system that includes a processor, the system capable of of executing a plurality of modes, the article comprising:
-
memory that can be accessed by the processor; and
data stored in the memory, the data comprising;
a mixed mode field for differentiating between modes, said mixed mode field capable of specifying at least a first and second state, said mixed mode field being set to a specific, predetermined value when in said second state;
means for specifying a software routine; and
a procedure information field for indicating a mechanism capable of initiating the execution of the specified software routine and for specifying one or more characteristics of parameters to be used by the executing specified software routine. - View Dependent Claims (5, 6)
a stack arranged so that it can be accessed by the processor, said stack having a first stack frame associated with a first code segment and a second stack frame associated with a second code segment, said first and second stack frames having different formats; and
a stack switch frame, positioned between said first and said second stack frames, said stack switch frame having a first segment referencing the first stack frame, a second segment having parameters in a format of the second stack frame, said parameters having been converted from a format of the first stack frame, and a third segment specifying information so that the stack switch frame is in a format that can be referenced by the second stack frame.
-
Specification