100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
TEST BANK FOR Computer Systems A Programmer's Perspective 1st Edition By Randal E. Bryant and David R. O'Hallaron $17.49   Add to cart

Exam (elaborations)

TEST BANK FOR Computer Systems A Programmer's Perspective 1st Edition By Randal E. Bryant and David R. O'Hallaron

 61 views  0 purchase
  • Course
  • Institution

Exam (elaborations) TEST BANK FOR Computer Systems A Programmer's Perspective 1st Edition By Randal E. Bryant and David R. O'Hallaron Computer Systems: A Programmer’s Perspective Instructor’s Solution Manual 1 Randal E. Bryant David R. O’Hallaron December 4, 2003 1Copyright

Preview 4 out of 89  pages

  • January 30, 2022
  • 89
  • 2021/2022
  • Exam (elaborations)
  • Unknown
avatar-seller
2

, Computer Systems: A Programmer’s Perspective
Instructor’s Solution Manual 1




Randal E. Bryant
David R. O’Hallaron

December 4, 2003




1
Copyright c 2003, R. E. Bryant, D. R. O’Hallaron. All rights reserved.

,Chapter 1

Solutions to Homework Problems

The text uses two different kinds of exercises:

Practice Problems. These are problems that are incorporated directly into the text, with explanatory
solutions at the end of each chapter. Our intention is that students will work on these problems as they
read the book. Each one highlights some particular concept.

Homework Problems. These are found at the end of each chapter. They vary in complexity from
simple drills to multi-week labs and are designed for instructors to give as assignments or to use as
recitation examples.

This document gives the solutions to the homework problems.


1.1 Chapter 1: A Tour of Computer Systems

1.2 Chapter 2: Representing and Manipulating Information

Problem 2.40 Solution:
This exercise should be a straightforward variation on the existing code.
code/data/show-ans.c

1 void show_short(short int x)
2 {
3 show_bytes((byte_pointer) &x, sizeof(short int));
4 }
5
6 void show_long(long int x)
7 {
8 show_bytes((byte_pointer) &x, sizeof(long));
9 }


1

, 2 CHAPTER 1. SOLUTIONS TO HOMEWORK PROBLEMS

10
11 void show_double(double x)
12 {
13 show_bytes((byte_pointer) &x, sizeof(double));
14 }

code/data/show-ans.c

Problem 2.41 Solution:
There are many ways to solve this problem. The basic idea is to create some multibyte datum with different
values for the most and least-significant bytes. We then read byte 0 and determine which byte it is.
In the following solution is to create an int with value 1. We then access its first byte and convert it to an
int. This byte will equal 0 on a big-endian machine and 1 on a little-endian machine.
code/data/show-ans.c

1 int is_little_endian(void)
2 {
3 /* MSB = 0, LSB = 1 */
4 int x = 1;
5
6 /* Return MSB when big-endian, LSB when little-endian */
7 return (int) (* (char *) &x);
8 }

code/data/show-ans.c

Problem 2.42 Solution:
This is a simple exercise in masking and bit manipulation. It is important to mention that ˜0xFF is a way
to generate a mask that selects all but the least significant byte that works for any word size.
(x & 0xFF) | (y & ˜0xFF)

Problem 2.43 Solution:
These exercises require thinking about the logical operation ! in a nontraditional way. Normally we think
of it as logical negation. More generally, it detects whether there is any nonzero bit in a word.

A. !!x

B. !!˜x

C. !!(x & 0xFF)

D. !!(˜x & 0xFF)


Problem 2.44 Solution:

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller Exceldemics. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $17.49. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

80796 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling

Recently viewed by you


$17.49
  • (0)
  Add to cart