SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Linda Null ,julia Lobur
Chapter:
A Closer Look At Instruction Set Architectures
Exercise:
Exercises
Question:5 | ISBN:9780763704445 | Edition: 3

Question

5. The Population Studies Institute monitors the population of the United States. In 2000, this institute wrote a program to create files of the numbers representing populations of the various states, as well as the total population of the U.S. This program,which runs on a Motorola processor, projects the population based on various rules,such as the average number of births and deaths per year. The institute runs the program and then ships the output files to state agencies so the data values can be used as input into various applications. However, one Pennsylvania agency, running all Intel machines, encountered difficulties, as indicated by the following problem.

When the 32-bit unsigned integer 1D2F37E816 (representing the overall U.S. population prediction for 2003) is used as input, and the agency’s program simply outputs this input value, the U.S. population forecast for 2003 is far too large. Can you help this Pennsylvania agency by explaining what might be going wrong?

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

The problem faced by the Pennsylvania agency when running the program on Intel machines is likely due to the difference in endianness between the Motorola processor used by the Population Studies Institute and the Intel processors used by the agency.

The 32-bit unsigned integer value 1D2F37E816 represents the overall U.S. population prediction for 2003. However, endianness determines the byte order in which the individual bytes of the integer are stored in memory.

If the Population Studies Institute program running on the Motorola processor uses big endian representation, the bytes of the integer are stored in the following order:

1D 2F 37 E8

However, Intel processors use little endian representation, where the bytes are stored in the reverse order:

E8 37 2F 1D

  • When the Pennsylvania agency's program running on Intel machines simply outputs the input value without accounting for the endianness difference, the bytes are read in reverse order.
  • Consequently, the agency's program interprets the bytes as a different value, leading to an incorrect U.S. population forecast for 2003.
  • To resolve this issue, the Pennsylvania agency's program needs to account for the endianness difference between the two processor architectures.
  • It should reverse the byte order of the input value before using or interpreting it. By properly handling the byte order, the agency's program can obtain the correct U.S. population forecast value.
0 0

Discussions

Post the discussion to improve the above solution.