Discussion:
Homework #2: A Solution
(too old to reply)
Wayne Heym
2005-10-15 15:07:32 UTC
Permalink
Only three days late this time!
http://www.cse.ohio-state.edu/~heym/360/common/now/hw2-answer.html
<http://www.cse.ohio-state.edu/%7Eheym/360/common/now/hw2-answer.html>
--
Wayne
Nick McCowin
2005-10-16 16:01:48 UTC
Permalink
CSE 360 Homework #2: A SolutionIn a consistent Little Endian scheme shouldn't the bits also be read from right to left? It seems like the solution for #10b is assuming that the system is using an inconsistent Little Endian scheme since each byte has been written down exactly as it is in memory.

10.. Suppose the system described above uses a consistent Little Endian byte addressing scheme and has the following contents in part of memory:


Address
Contents

16400
0x50

16401
0x65

16402
0x72

16403
0x66

16404
0x65

16405
0x63

16406
0x74

16407
0x00





------------------------------------------------------------------------------

b. Two integers each encoded according to the 32-bit 2's complement scheme. (Show a decimal representation of each integer.) (5 pts)
Wayne D. Heym
2005-10-16 23:04:00 UTC
Permalink
Post by Nick McCowin
In a consistent Little Endian scheme shouldn't the bits also be read
from right to left? It seems like the solution for #10b is assuming
that the system is using an inconsistent Little Endian scheme since
each byte has been written down exactly as it is in memory.
This matter is ripe for many possible confusions. Thanks for thinking
hard about it and asking a good question. It can take a while to sort
out the conventions people use to communicate.

The ordering of the bits is actually irrelevant here. The Contents
column of the table is telling us not so much the exact bit layout in
memory, but (as it happens, in hexadecimal notation) the unsigned
numeric value of the memory cell. These values range from 0 through 2^8
- 1, or 0 through 255, or 0 through 0xFF, or 0 through 0b11111111. Even
the binary representation of such a value, say, 0b1010000, doesn't take
a position on bit ordering in memory, it only relies on the convention,
that, on paper, chalkboard, display screen, or any other format intended
for human eyes in North America, the less significant the digit, the
further out to the right it lies.

The Little Endian memory storage scheme is defined only in terms of the
ordering of the bytes, not in terms of bit ordering within a byte. It
is defined in terms of the values of each of the bytes. Hence, the
value represented in addresses 16404 through 16407 in the example is
0x65 * 16^0 + 0x63 * 16^1 + 0x74 * 16^2, which, by the hexadecimal
convention may be written as 0x746365. (It's also, of course 101 * 16^0
+ 99 * 16^1 + 116 * 16^2, or 101 + 99 * 16 + 116 * 256.)

As for the consistency of bit ordering, consistent Little Endian means
that the bit number given to the least significant bit is 0. However,
often bit number zero is written on paper out to the right. Where bit
number zero is physically in memory is open to many possibilities.

The value in the example stored in address 16400 (0x50) could be
expressed on paper with bit numberings in either of the following two
ways. Both ways are consistent Little Endian.

76543210
01010000

01234567
00001010

To get an inconsistent Little Endian, all we would need to do would be
to change the bit numbering scheme:

01234567
01010000
--
Wayne
Continue reading on narkive:
Loading...