100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Solutions Manual Computer Systems A Programmer’s Perspective 3rd Edition! ALREADY RATED A+ 100% CORRECT ANSWERS

Rating
-
Sold
-
Pages
118
Grade
A+
Uploaded on
02-12-2025
Written in
2025/2026

Solutions Manual Computer Systems A Programmer’s Perspective 3rd Edition! ALREADY RATED A+ 100% CORRECT ANSWERS

Institution
A Programmer’s Perspective 3rd Edition
Module
A Programmer’s Perspective 3rd Edition











Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
A Programmer’s Perspective 3rd Edition
Module
A Programmer’s Perspective 3rd Edition

Document information

Uploaded on
December 2, 2025
Number of pages
118
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Solutions Manual Computer Systems A Programmer’s Perspective 3rd Edition
ammer’s Perspective 3rd Ed ition So lutions Manua l Co mputer Syste ms A Programmer’s Perspective 3rd Edition Solu tions Manual Comp uter Sy stems A Programmer’s Perspective 3rd Edition




Solutions Manual Computer Systems A Programmer’s Perspective 3rd Edition




Solutions Manual Computer Systems A Programmer’s Perspective 3rd Edition

,Solutions Manual Computer Systems A Programmer’s Perspective 3rd Edition
ammer’s Perspective 3rd Ed ition So lutions Manua l Co mputer Syste ms A Programmer’s Perspective 3rd Edition Solu tions Manual Comp uter Sy stems A Programmer’s Perspective 3rd Edition




Chapter 1

Solutions to Homework Problems

This document contains solutions for the international version of the Second Edition of the book (we call
this “Version B”). A separate document contains solutions for the North American version (Version A).
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

There are no homework problems in this chapter.


1.2 Chapter 2: Representing and Manipulating Information

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

1 void show_short(short x) {
2 show_bytes((byte_pointer) &x, sizeof(short));
3 }
4




Solutions Manual Computer Systems A Programmer’s Perspective 3rd Edition

,4 CHAPTER 1. SOLUTIONS TO HOMEWORK PROBLEMS

5 void show_long(long x) {
6 show_bytes((byte_pointer) &x, sizeof(long));
7 }
8
9 void show_double(double x) {
10 show_bytes((byte_pointer) &x, sizeof(double));
11 }

code/data/show-ans.c

Problem 2.58 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.
The following solution creates 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_big_endian(void) {
2 /* MSB = 0, LSB = 1 */
3 int x = 1;
4 /* MSB (0) when big-endian, LSB (1) when little-endian */
5 char byte = *(char *) &x;
6 return !byte;
7 }

code/data/show-ans.c

Problem 2.59 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.60 Solution:
Byte extraction and insertion code is useful in many contexts. Being able to write this sort of code is an
important skill to foster.
code/data/rbyte-ans.c

1 unsigned put_byte (unsigned x, unsigned char b, int i) {
2 int itimes8 = i << 3;
3 unsigned mask = 0xFF << itimes8;
4
5 return (x & ˜mask) | (b << itimes8);
6 }

code/data/rbyte-ans.c

, 1.2. CHAPTER 2: REPRESENTING AND MANIPULATING INFORMATION 5

Problem 2.61 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. In addition,
it gives practice with masking.

A. !!x
B. !!˜x
C. !!(x & (0xFF << ((sizeof(int)-1)<<3)))
D. !!(˜x & 0xFF)


Problem 2.62 Solution:
There are many solutions to this problem, but it is a little bit tricky to write one that works for any word
size. Here is our solution:
code/data/shift-ans.c

1 int int_shifts_are_logical() {
2 int x = -1; /* All 1’s */
3 return (x >> 1) > 0;
4 }

code/data/shift-ans.c
The above code performs a right shift of a word in which all bits are set to 1. If the shift is logical, the
resulting word will become positive.

Problem 2.63 Solution:
These problems are fairly tricky. They require generating masks based on the shift amounts. Shift value 0
must be handled as a special case, since otherwise we would be generating the mask by performing a left
shift by 32.
code/data/rshift-ans.c

1 int sra(int x, int k)
2 {
3 /* Perform shift logically */
4 int xsrl = (unsigned) x >> k;
5 /* Make mask of high order k bits */
6 unsigned mask = k ? ˜((1 << (8*sizeof(int)-k)) - 1) : 0;
7
8 return (x < 0) ? mask | xsrl : xsrl;
9 }

code/data/rshift-ans.c
code/data/rshift-ans.c

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
AcademicAssignments University of Phoenix
View profile
Follow You need to be logged in order to follow users or courses
Sold
627
Member since
6 year
Number of followers
453
Documents
1068
Last sold
21 hours ago

Help in all Courses Dq's, Assignments and MCQs, Midterm &amp; Final Exams Experience: 15 Years in the online teaching field.

3.8

86 reviews

5
42
4
16
3
12
2
5
1
11

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions