Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 ggr 10/28/83; site pyuxbb.UUCP Path: utzoo!watmath!clyde!floyd!harpo!ihnp4!pyuxbb!drew From: drew@pyuxbb.UUCP (RD Davis) Newsgroups: net.arch Subject: Re: Complement Arithmetic, -0 as a tag Message-ID: <356@pyuxbb.UUCP> Date: Thu, 2-Feb-84 18:36:27 EST Article-I.D.: pyuxbb.356 Posted: Thu Feb 2 18:36:27 1984 Date-Received: Wed, 8-Feb-84 01:43:32 EST References: <5260@uiucdcs.UUCP> <262@pyuxss.UUCP> Organization: AT&T Bell Laboratories, Piscataway Lines: 34 The PL/C compiler is a PL/I implementation intended for quick compiles and maximum diagnostic assistance at run-time, even if the price of this was some sacrifice in run-time performance. (However, it was a genuine compiler, not an interpreter like the PL/I-Checkout "Compiler"). An implementation detail I recall from PL/C that is relevant to this discussion of 2's complement vs. 1's complement: PL/C arranged for all fixed binary variables to be initialized to the most negative integer. Unless a compile time option was specified to turn off checking for uninitialized variables, the compiler generated an extra "load complement" instruction for every use of such a variable. The overhead of this extra instruction was very small. However, since PL/C programs ran on a 2's-complement machine, complementing the most negative number caused an overflow to occur. Such overflow's were trapped and the trap routine diagnosed exactly what was wrong to give a message about a reference to an uninitialized variable (cleanly naming the variable name & statement number and even "fixing" the problem by initializing the variable for you [to zero? or was it to 1?]). Point is, that here is an example of exploiting the asymmetry of the 2's complement domain. This trick gave low overhead for valid references, and still gave run-time checking for uninitialized integer variables. By the way, the PL/I declaration for fixed binary variables seems to be implicitely assuming "sign/magnitude" representation. For example, on the IBM 370, with 32 bit registers, the maximum bits allowed by the PL/I implementation is BIN(31). Handily for the PL/C implementors, this constraint meant that the most negative integer was not an acceptable value for a PL/I program to store in such a variable. That is, an operation that yielded the most negative integer as a result, could properly be diagnosed as having exceeded the bounds permitted by the language. R. Drew Davis AT&T Bell Laboratories pyuxbb!drew