Browse Prior Art Database

PRECISION Testing by Dynamically Using the CTLZ Instruction

IP.com Disclosure Number: IPCOM000043082D
Original Publication Date: 1984-Jul-01
Included in the Prior Art Database: 2005-Feb-04
Document File: 3 page(s) / 22K

Publishing Venue

IBM

Related People

Chroust, G: AUTHOR

Abstract

The CTLZ (count leading zeroes) instruction (of IBM 8100) provides a convenient means for detecting in software those cases where the precision of a value exceeds the language-defined precision. Compared with standard methods (see below), the use of the CTLZ instruction requires less code. The CTLZ instruction is defined as follows: CTLZ r1,r2 where r1 and r2 are halfwords. A count of the number of leading (left-most) 0-bits in the second operand halfword is placed in the first operand location (r1), and the left-most 1-bit in the second operand (r2) is made 0. Thus, the CTLZ instruction modifies r1 and r2. The PL/I program language works from the notion of precision being associated with arithmetic variables.

This text was extracted from a PDF file.
At least one non-text object (such as an image or picture) has been suppressed.
This is the abbreviated version, containing approximately 55% of the total text.

Page 1 of 3

PRECISION Testing by Dynamically Using the CTLZ Instruction

The CTLZ (count leading zeroes) instruction (of IBM 8100) provides a convenient means for detecting in software those cases where the precision of a value exceeds the language-defined precision. Compared with standard methods (see below), the use of the CTLZ instruction requires less code. The CTLZ instruction is defined as follows: CTLZ r1,r2 where r1 and r2 are halfwords. A count of the number of leading (left-most) 0-bits in the second operand halfword is placed in the first operand location (r1), and the left-most 1-bit in the second operand (r2) is made 0. Thus, the CTLZ instruction modifies r1 and r2. The PL/I program language works from the notion of precision being associated with arithmetic variables. Precision defines the number of significant digits of these variables and may have any value ranging from 1 to an implementation-defined maximum of, say, 31, for fixed binary values. The internal representation of a variable must use the storage units available, such as halfwords, fullwords, etc., thus not being a direct reflection of the respective precision. The selected storage unit (e.g., halfwords for precisions from 1 to 15) must accommodate at least the significant digits but usually provides more digits than are required. (The figure below shows a variable of precision 12 in a halfword.)

(Image Omitted)

From the language point of view, it is necessary to detect all cases where a value exceeds the language-specified precision. Hardware only signals such cases if the physical size of the storage unit is exceeded, too. If the precision of a fixed binary variable is not known at the time of compilation (as is the case with library subroutines called for handling variables of different precision), standard methods of precision testing are either unsuitable or can be applied only with considerable difficulty. Let p be the declared (binary) precision of a variable W, let W be contained in a halfword named VARIABLE, and let Rl and R2 be halfword registers. The subsequent pseudo-code assumes positive values of VARIABLE and is used to test whether the value contained in the halfword VARIABLE exceeds the (variable) precision p. LOAD R1 FROM VARIABLE

CTLZ R2,R1

if R2 < (15-p) THEN 'precision exceeded'. One possibility of coding the third line of the above pseudo-code is described below. Let PRECISION be a storage location containing the precision of the variable. LOAD R1,PRECISION SHRI R1,15 ... subtract immediate value 15 from p

AHR R2,R1 ... compute count + (p-15)

E-minus ... ... branch on minus (count < 15-p))

to 'precision exceeded' For negative numbers in twos complement notation, the value of the variable must be complemented before testing. For higher precisions,...