Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site calgary.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!ihnp4!alberta!calgary!radford From: radford@calgary.UUCP (Radford Neal) Newsgroups: net.arch Subject: Re: Strange architecture proposal Message-ID: <993@calgary.UUCP> Date: Wed, 20-Feb-85 17:55:33 EST Article-I.D.: calgary.993 Posted: Wed Feb 20 17:55:33 1985 Date-Received: Tue, 26-Feb-85 04:04:47 EST References: <968@calgary.UUCP> <289@petrus.UUCP> Distribution: net Organization: University of Calgary, Calgary, Alberta Lines: 53 > ... Perhaps it would be more convenient to put the > size encoding bits on the right. The automatic "stride adjustment" > feature goes away, but addresses no longer have to be shifted before > use, the effects of arithmetic overflow during address computation > are less painful, and direct comparison of pointers to objects of > different sizes makes a little more sense.... The effects of overflow would indeed be more "expected" (wrap-around to the beginning of memory rather than total garblement into a different kind of pointer). However I'm not sure you save by getting rid of the shift. The format of a pointer to a long would in that scheme be something like A8 A7 A6 A5 A4 A3 A2 1 0 0 A1 and A0 would still have to be converted to 0 0 rather than 1 0, which might be as bothersome as a shift. Comparisons of pointers to different types could be done by casting them to a common type as described below. > I think the main problem with encoding size in addresses is that it > would be necessary to override encoded size too often... A properly written C program will use casts for all changes of pointer type. E.g. short *a; ... *(char*)a = 1; The cast in this code would be a run-time operation (shift left by one). In the other direction - char *b; ... *(short*)b = 1; The code is not guaranteed to work unless the pointer is properly aligned. The run-time code for the cast is a shift right by one. A special shift operation could be used that trapped if a one bit was shifted out, thus detecting an alignment error at the time of the cast rather than when the pointer is used (possibly much later). All this requires only one additional machine instruction to handle type overrides, which doesn't seem excessive even if they are common, which they shouldn't be in modern programs. BTW: One advantage of the scheme I hadn't thought of before is that is certainly guarantees that zero isn't a valid pointer... -:) Radford Neal The University of Calgary