Specialized millicode instruction for range checking5621909Abstract A range check instruction sequence, which performs a logical comparison between two 32-bit values and updates the condition code as a result. It operates identically to the ESA/390 instruction compare logical (CLR) except for the way in which the condition code is set. The new condition code is a function of both the comparison result and the previous condition code. If the first operand is greater than the second operand, the condition code remains unchanged. If the first operand is less than or equal to the second operand, the condition code is set to 2 if it was previously 0 or 1, and is set to 3 if it was previously 2 or 3. This may be understood as advancing the state of the condition code among the groups (0,1), 2, and 3 if the first operand is not greater than the second operand. Claims Having thus described our invention, what we claim as new and desire to secure by Letters Patent is as follows: Description BACKGROUND OF THE INVENTION
______________________________________
CLR RX,RZ
CLRNG RX,RY
CLRNG RY,RZ
______________________________________
The CLR instruction sets the condition code to 0 if (X<Z), to 1 if (X=Z), and to 2 if (X>Z). The first CLRNG instruction changes the condition code from 0 or 1 to 2, or from 2 to 3, if (X.ltoreq.Y), and leaves the condition code unchanged otherwise. The second CLRNG instruction changes the condition code from 0 or 1 to 2, or from 2 to 3, if (Y.ltoreq.Z), and leaves the condition code unchanged otherwise. Thus if: [(X.ltoreq.Z) and (X.ltoreq.Y) and (Y.ltoreq.Z)] then the condition code will be 0 or 1 after the CLR; it will be changed to 2 by the first CLRNG instruction and then to 3 by the second CLRNG instruction. Similarly, if: [(X>Y) and ((X.ltoreq.Y) or (Y.ltoreq.Z))] then the condition code will be 2 after the CLR and will be changed to 3 by one of the two CLRNG instructions, depending on whether (X.ltoreq.Y) or (Y.ltoreq.Z) is true. For any other consistent relationships of X, Y and Z, the condition code at the end of the sequence will be 0, 1 or 2. Thus the code may issue these three instructions and then test the condition code once to determine if Y is in the range (X,Z); this is the case if and only if the final condition code is 3. BRIEF DESCRIPTION OF THE DRAWINGS The foregoing and other objects, aspects and advantages will be better understood from the following detailed description of a preferred embodiment of the invention with reference to he drawings in which: FIG. 1 is a block diagram illustrating the components of a millicode system in accordance with a preferred specific embodiment of the invention. FIG. 2 is a flow diagram of the compare logical for range check operational steps in accordance with the teachings of this invention. DETAILED DESCRIPTION OF A PREFERRED EMBODIMENT OF THE INVENTION This following exemplary embodiment of the invention is applicable in the overall context of a system generally conforming to IBM 390 system architecture. A more detailed description of the conventional elements of such a 390 system processor can be found, for example, in U.S. Pat. No. 4,901,233 to John S. Liptay, assigned to the same assignee as the present invention, and incorporated by reference, in its entirety, as if printed in full below. While the System 390 environment will be used as an example, it should be understood that the present invention is also readily applicable to other IBM (e.g. IBM System 370) and non-IBM architectures as well. While not limited thereto, the invention is particularly well suited for use in conjunction with the enhanced error recovery system described in copending application attorney docket P09-93-035, Ser. No. 08/149,260, filed Nov. 9, 1993, assigned to the assignee of this application, and also incorporated herein by reference. Referring now to FIG. 1, elements of a system relevant to this invention include a system storage 11, and a cache memory unit 12. The system storage 11 contains the instructions that the processor is executing as well as the data those instructions are manipulating. The cache memory unit 12, which includes a copy of the data and instructions the processor is presently executing, in this preferred embodiment is a cache providing interleaved double word addressing. The cache memory 12 logically includes a contiguously addressable read only store 13, in which code for executing certain frequently invoked milli-mode routines is stored. An instruction unit subsystem 16 includes an instruction buffer (not shown in FIG. 1), instruction registers 18 and an instruction decoder 20. The instruction unit subsystem receives macro-instructions, millicode instructions, and data from the cache memory unit 12. Instructions are parsed and placed into the instruction registers 18. The decoder 20 reads the contents of the instruction registers 18, decodes the instruction (or causes an operation exception), and passes the instruction to an instruction queue for sequential execution by a hardware execution unit 24. Each hardware execution unit 24 has access to a set of general purpose registers and access registers 21 for normal macro-code instruction execution and to a set of general purpose registers and access registers 23 for millicode instruction execution. Control logic controls the exchange of data between the two sets of registers when beginning or terminating a millicode routine. Milli-mode detection logic 26 is coupled to the instruction registers and detects when a macro-instruction, which is being decoded, is of a type that is to be interpreted in a milli-mode operation. When this occurs, the milli-mode detection logic 26 generates an entry point address and passes this address along to the instruction fetch control logic 25 and places the decoder 20 into a milli-mode operating state. In this state the decoder is enabled to decode milli-mode instructions. Milli-mode instructions are vertical microcode, consisting of a mixture of regular microcode instructions and special milli-mode only instructions, all of which can be executed in the execution unit 24. The special instructions provide control functions needed by the millicode routines. The set of millicode routines reside outside of the program addressable storage. The system effects of an executed instruction are architecturally visible in the completion logic 30. Signal lines between the completion logic 30 and the decoder 20 allow the decoder 20 to keep track of instruction completion. A program status word (PSW) in register 31 controls execution of the macro-program. Similarly, the system also includes a milli-PSW register 33, which controls execution of the milli-routine. Both the execution unit 24 and the completion logic 30 are connected to read from/write to the PSW and the milli-PSW registers. Thus, at any given point the execution units or the completion logic can read or update the appropriate one of the PSW and/or milli-PSW registers. A processor state unit 40 maintains the entire updated status of the architected system both in regular mode and milli-mode operation. In the event of a detected error, the processor state unit 40 provides a resource to recreate the status of the system from a check point state in order to allow a retry of the error causing operation. Milli-mode is enabled when the milli-mode detection logic 26 recognizes that the macro-instruction being decoded is to be implemented with millicode. In response to this recognition, the detection logic 26 signals the decoder 20, the instruction fetch controls 35 and register controls in the execution unit 24. In response to the milli-mode recognition signal from the detection logic 26, the decoder 20 suspends macro-mode decoding, the execution unit register control copies the contents of the GPRs 21 to the milliregisters 23 and causes the system to subsequently use the milli-registers 23. The milli-mode detection logic 26 generates a millicode entry point address. The entry point address (generated by the milli-mode detection logic 26) is used by the control logic 35 to address the cache 12. Milli-instructions from the cache are sent to the instruction registers 18 where the decoder 20 decodes them and schedules them for execution. When the processor enters milli-mode, it executes and completes the macro-instructions already in the pipeline conceptually prior to the instruction that caused entry into milli-mode. As the processor completes the macroinstructions, it updates the appropriate GPRs. At the same time, the processor decodes and executes the milliinstructions that implement the macro-instruction that caused entry into milli-mode. At some point the macro-instruction immediately prior to the instruction that caused entry to milli-mode will be indicated completed in the completion logic 30. Only then does the processor begin to complete the milli-instructions. The processor then continues decoding, executing and completing the milli-instructions. Eventually, the detection logic 26 recognizes a millicode END (MEND) milli-instruction. When the detection logic 26 detects a MEND milli-instruction, it causes the processor to cease fetching milli-instructions. Further, when MEND is detected, the detection logic puts the decoder in macro-mode and causes the processor to begin fetching macro-instructions. Millicode explicitly updates all registers, so there is no transfer of register content when going from milli-mode operation to regular operation. Completion of a MEND milli-instruction causes the processor completion logic to begin completing macroinstructions. The processor can also enter milli-mode in response to an interrupt. When the completion logic detects an interrupt, the interrupt priority logic 45 determines that an interrupt is to be serviced and it signals the instruction fetch unit, causing the decoder to initiate milli-mode. The recognition of an interruption condition causes the processor to halt macro-mode execution at the next interruptible point. The interrupt priority logic 45 also generates control inputs which are used by the milli-mode detection logic to generate an entry point address with which to address the cache. These milli-instructions are sent to the instruction registers where the decoder decodes them and schedules them for execution at the appropriate hardware execution elements. The processor proceeds to decode, execute and complete the milli-instruction in the milli-routine for interrupts. Eventually, the decoder recognizes a MEND milli-instruction. This causes the decoder to stop decoding in milli-mode. Depending on whether or not there are additional interrupts that require servicing, the decoder hardware will either redo the interrupt process or return to decoding macroinstructions from the cache. In the execution of the range checking instruction:
______________________________________
'B2CB' //////////// R1 R1
0 16 24 28 31
______________________________________
millicode registers R1 and R2 are compared, and a condition code is modified based upon the result of the comparison. Referring now to FIG. 2, the condition code is a function of both the comparison and the previous condition code, to allow this instruction to be used in a sequence that performs a range check. If the result of the comparison is that MGR R1 is greater than MGR R2, the condition code is not changed. Otherwise (i.e. when MGR R1 is less than or equal to MGR R2) the condition code is set to 2 if the previous condition code was 0 or 1, and to 3 if the previous condition code was 2 or 3. The condition code settings are defined as follows:
______________________________________
CC Condition
______________________________________
0 MGR R1 greater than MGR R2, and previous CC = 0
1 MGR R1 greater than MGR R2 and previous CC = 1
2 MGR R1 greater than MGR R2, and previous CC = 2;
or MGR R1 less than or equal to MGR R2 and previous
CC = 0 or 1
3 Previous CC = 3, or MGR R1 less than or equal to
MGR R2 and previous CC = 2
______________________________________
This instruction is intended for use as part of a sequence to determine if one value (Y) is in the range (X,Z), where the range may be "inverted" (i.e. X>Z). (An example of this is the PER address range check, where CR10 contains X, CR11 contains Z, and Y is the address being checked). Y is defined to be in the range if: [(X.ltoreq.Z) and (X.ltoreq.Y) and (Y.ltoreq.Z)] or [(X>Z) and ((X .ltoreq.Y) or (Y.ltoreq.Z))] This can be performed using three instructions as follows:
______________________________________
CLR RX,RZ
CLRNG RX,RY
CLRNG RY,RZ
______________________________________
where RX, RY and RZ designate MGRs containing X, Y and Z, respectively. the condition code at the end of the sequence will be 3 if Y is in the range (X,Z) and 2 otherwise. Note that a "logical" comparison is performed, and that bit 0 of the MGRs participates in the comparison. If the values being compared are addresses, millicode must insure that bit 0 is masked off in the operands for CLRNG. While the invention has been described in terms of a single preferred embodiment, those skilled in the art will recognize that the invention can be practiced with modification within the spirit and scope of the appended claims.
|
Same subclass Same class Consider this |
||||||||||
