sumedh..... wrote:
In a compiler there are 36bits for a word and to store a character
8bits are needed. In this to store a character two words appended.
Then for storing k characters string,how many words are needed?
I suppose this is homework, so it's probably a good thing that the
question is not stated clearly. In particular, it is underspecified.
Suppose that you have 10 bytes to recover. These can be in 9 bytes in
one conjoined 72-bit chunk + 1 more byte. Must you retrieve two words
(a 72-bit bit chunk) for that last byte, or can you do it with only one
more 36-bit word? The answer in this case could be either 3 or 4 words.
Let's consider some real-life cases.
The major 36-bit word machines I have used are in the IBM 7090/7094, DEC
PDP-6/PDP-10, and GE 635/645 families. In all of these, addressing of
bytes had to be to groups of contiguous bits within a word. That meant
that the world you seem to be concerned with did not obtain: two
contiguous 36-bit words could not be treated as one 72-word for purposes
of byte addressing. Hoe, then, does one handle bytes.
In the GE 635/645 case, a common answer was to use 9-bit bytes. This
meant one could have a 512 character character set, or 256 characters
with a bit used as a flag of some sort, or just a wasted bit per char.
In the PDP 6/PDP-10 case, where a byte pointer stored the base word
address, the size of a byte (1-36 bits) and the position of the next
byte (relative to the end of the word), the normal choices were
a) 6x6-bit bytes, inappropriate for C, but useful in situations
where case sensitivity was not needed
a') an even more restricted set of 40 characters (RAD50) which were
rarely interpreted, but rather an encoded word was created and
used in symbol tables. much as a password look up table.
b) 5x7-bit bytes, with the last bit either wasted of used as a
flag. Inappropriate for C, but capable of handling ASCII text.
c) 4x8-bit bytes, with 4 bits either wasted or used as a set of
flags. C chars can be accommodated within this scheme, but attempts
to fit this into a coherent integer type system can be tricky.
d) 4x9-bit bytes, as in the GE 635/645 case. This accommodates C chars
nicely, and because the PDP-6/PDP-10 series have instructions for
retrieving and storing either the right or left hand 18-bits of a
word separately, it is trivial to implement using the basic
instruction set for the machine a type system including
9-bit chars
18-bit shorts
36-bit int
and, if you choose to make ints and longs different lengths,
72-bit longs can be added at small cost in computation.