Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!rochester!rutgers!sri-spam!ames!oliveb!jerry
From: jerry@oliveb.UUCP (Jerry F Aguirre)
Newsgroups: comp.unix.wizards,comp.arch
Subject: Re: Power-of-2 (Was : *Why* 8-bit bytes?)
Message-ID: <2212@oliveb.UUCP>
Date: Wed, 22-Jul-87 15:09:19 EDT
Article-I.D.: oliveb.2212
Posted: Wed Jul 22 15:09:19 1987
Date-Received: Fri, 24-Jul-87 06:03:33 EDT
References: <142700010@tiger.UUCP> <2792@phri.UUCP> <8315@utzoo.UUCP> <2807@phri.UUCP> <23967@sun.uucp>
Reply-To: jerry@oliveb.UUCP (Jerry F Aguirre)
Organization: Olivetti ATC; Cupertino, Ca
Lines: 26
Xref: mnetor comp.unix.wizards:3364 comp.arch:1662

In article <23967@sun.uucp> lyang@sun.UUCP (Larry Yang) writes:
>One reason I can think for having power-of-2 sizes is in terms of addressing.
>If a word = 4 bytes, then I can address a word by masking out the lower
>2 bits.  If a word were 5 bytes, this would be more difficult.  I can fill
>a 64-byte cache line by masking out the lower 6 bits of the address.  And
>so on.  This doesn't explain why a byte size has to be 8 bits, however.

But it does!  If the machine supports bit addressing and you want to
convert from one address to another then being able to just shift or
mask is a desirable feature.  The alternative is to require a multiply
or divide for address casting.

This is not something that the average C programer faces because C
doesn't support bit addressing or arrays of bits.  I consider that a
shortcomming of C.  I have worked on systems that supported bit
addresses and bit test/set/clear instructions.  It is much more natural
to think of an array of N true false variables then to go thru the
complication of trying to pack them into some structure.

Also regarding a previous comment I don't see why multiple shifts are
contrary to "risc" design.  Modern computers use a barrel shifter that
can shift any number of places in one cycle.  The hardware doesn't have
to shift 1, decrement a counter, and repeat.  Shifting is a very common
operation and not one that a compiler had trouble taking advantage of.

					Jerry Aguirre