Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 beta 3/9/83; site desint.UUCP Path: utzoo!watmath!clyde!bonnie!akgua!sdcsvax!sdcrdcf!trwrb!desint!geoff From: geoff@desint.UUCP (Geoff Kuenning) Newsgroups: net.lang.c Subject: Re: casts and puns (and digressions...) Message-ID: <229@desint.UUCP> Date: Mon, 19-Nov-84 20:37:20 EST Article-I.D.: desint.229 Posted: Mon Nov 19 20:37:20 1984 Date-Received: Wed, 21-Nov-84 01:31:07 EST References: <110@ISM780B.UUCP> <940@opus.UUCP> <210@desint.UUCP> <9890@watmath.UUCP> Organization: his home computer, Manhattan Beach, CA Lines: 47 In article <9890@watmath.UUCP> kpmartin@watmath.UUCP (Kevin Martin) writes: >In article <210@desint.UUCP> geoff@desint.UUCP (Geoff Kuenning) writes: >> >>Oh yeah? How about non-byte-addressable machines? A C compiler for the DG >>Nova, for example, would have to generate a shift-right instruction for that >>cast. Sounds like a conversion to me. > > (Throw glass of cold water in person's face, grab then by the shoulders >and shake them, slap them in the face a few times, look them squarely in >the face, and, for the n+1st time, say...) > >On a NOVA, (int *)1 could just as well point at word 1, and (char *)1 >as the lower byte of word 1, and (char *)0100001 at the upper byte of >word 1, etc. In which case the cast really is a pun. > >If a C compiler for the NOVA does a shift for int->pointer conversions, >it is only through the kindness of heart (and/or lack of brains) on the part >of the compiler developers. It is tough enough making sure zero turns into >the machine's null pointer without having to make every integer point to >the corresponding byte too. Before you go around slapping people and throwing cold water in their face, Kevin, you should be sure what you are doing. Otherwise you are going to offend people. In this case, you have exhibited a fair amount of ignorance regarding the Nova, ignored statements in the latter part of the article, and accused a number of compiler writers who you have never met of a lack of brains. For your information, there are two ways one can do byte pointers on the Nova. One is to store an index of the i'th byte from location zero. The other is to use bit 15 as the byte pointer. But, with the Nova instruction set, testing bit 15 requires a shift. And bit 15 must be cleared before you access the word you want, because it is an indirect bit. If you store a "byte pointer", you can do the test, adjustment, and clearing of bit 15 in a single instruction. If you store the odd-byte bit in the high bit, not only is your heavily-used byte-get routine significantly slower, but you also have a really nasty problem with incrementing the things. Obviously, word pointers should be stored as word pointers for efficiency reasons. Thus, you have a machine where the optimal pointer representation differs depending on the type. 'Nuff said? -- Geoff Kuenning First Systems Corporation ...!ihnp4!trwrb!desint!geoff