100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten 4.2 TrustPilot
logo-home
Tentamen (uitwerkingen)

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

Beoordeling
-
Verkocht
-
Pagina's
118
Cijfer
A+
Geüpload op
02-12-2025
Geschreven in
2025/2026

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

Instelling
A Programmer’s Perspective 3rd Edition
Vak
A Programmer’s Perspective 3rd Edition











Oeps! We kunnen je document nu niet laden. Probeer het nog eens of neem contact op met support.

Geschreven voor

Instelling
A Programmer’s Perspective 3rd Edition
Vak
A Programmer’s Perspective 3rd Edition

Documentinformatie

Geüpload op
2 december 2025
Aantal pagina's
118
Geschreven in
2025/2026
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

Voorbeeld van de inhoud

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

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
AcademicAssignments University of Phoenix
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
627
Lid sinds
6 jaar
Aantal volgers
453
Documenten
1068
Laatst verkocht
23 uur geleden

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

3,8

86 beoordelingen

5
42
4
16
3
12
2
5
1
11

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Veelgestelde vragen