Mail all unlisted
errata and corrections to: starolis@ece.utexas.edu
Note: The number(s) in parentheses
next to each item refers to the edition and printing which contains the
error. That is, 1.1 indicates an error in the first edition's first
printing that has been corrected in subsequent printings, whereas (1.2) indicates
the error is in both the first and second printings of the first edition.
(2) indicates an error found in the second edition, which is currently only
available in the first printing.
Errata
Page xii, Appendix D Title. (1.1)
Should read: The C Programming Language
Page 22, Section 2.3. (1.1,1.2) Line
22:
Replace: add A to
the complement of A
With: add 1 to the complement of A
Page 33, Figure 2.2. (1.1,1.2)
Replace: N = -1S...
With: N = (-1)S...
Page 34, Example 2.8. (1.1) The
exponent field should be 10000001, not 10000011
Page 38, Problem 2.5. (1.1) Using 5
bits to represent each number, write...
Page 39, Problem 2.13. (1.1) binary
representations, not binary numbers
Page 39, Problem 2.14. (1.1,1.2)
Replace the current problem with the following:
Note that in the
ADD step performed below, the addition is independent
of what the two representations being added mean.
1. Represent the values 7 and -6 as 1's complement
integers. ADD the two
binary representations. What is the binary
result. What decimal value does
that 1's complement result represent.
2. Represent the values 7 and -6 as signed magnitude
integers. ADD the two
binary representations. What is the binary
result. What decimal value does
that signed magnitude result represent.
3. Represent the values 7 and -6 as 2's complement
integers. ADD the two
binary representations. What is the binary
result. What decimal value does
that 2's complement result represent.
Page 40, Problem 2.18. (1.1) Replace
the problem with the following:
Express the negative value -27 as a
2's complement integer, using 8 bits. Repeat, using 16 bits. Repeat, using 32
bits. What does this illustrate with respect to the properties of sign
extension, as they pertain to 2's complement representation?
Page 41, Problem 2.32. (1.1) In
Example 2.5, what are the masks used for?
Page 43, Problem 2.41 (1.1) ASCII
code for three is 0011 0011, instead of 0110 0011, as shown.
Page 44, Problem 2.14 (2)
Replace: Add the
following binary representaions.
With: Add the
following bit patterns.
Page 44, Problem 2.49 (1.1,1.2)
Append the following to the problem statement:
[Hint: In the
first four cases, express each value as a decimal number. In the fifth
case, express the value as a sequence of characters that one could type on a
keyboard, for example.]
Page 63, Section 3.3.4 (2) First
sentence of first paragraph should read:
Figure
3.17 illustrates…
Page 64, Section 3.5. (1.1,1.2) First
sentence should read:
We now have all
the tools we need to describe one of the most important structures in the
electronic digital computer, its memory.
Page 85, Problem 3.8. (2)
Replace Y = A AND (B OR C)
with Y = NOT ( A AND ( B OR C))
Page 87, Problem 4.5. (1.1,1.2) Part
2c, Change to:
Interpret
locations 6 and 7 as an IEEE Floating Point number. Location 6 contains
number[15:0]. Location 7 contains number[31:16].
Page 87, Problem 4.5. (1.1) Part 2d,
Change to: Interpret location 0 and 1 as unsigned integers.
Page 88, Problem 4.10. (1.1) NOT
instead of NOP
Page 99, Problem 5.3.4. (1.1,1.2) R2
is encoded wrong in the instruction. It should read 0110 001 010 011101.
Page 100, Figure 5.2. (1.1) The field
breaks are done wrong for the instruction at address x30FC, they should read:
1010 011 011110100
Page 102, Section 5.4.2. (1.1,1.2)
Lines -7 and
-9: Replace R4 with R3
Page 105, Figure 5.5. (1.1) Sentinel
is misspelled in the decision box
Page 105, Section 5.4.4. (1.1,1.2)
Line -1:
Replace: x3101
With: the instruction at x3001
Page 108, Figure 5.7. (1.1,1.2) The
formula in the Prepare Output box should read (R0 <- R2 + x30)
Page 114, Problem 5.1. (1.1) First
line: NOT instead of NOP
Page 114, Problem 5.2. (1.1) Rephrase
as: What is the page number for each of the following LC-2 memory addresses?
Express your answers in hex.
Page 115, Problem 5.5. (1.1) Change
parts 2, 3, and 4 as follows:
2. Write an LC-2
instruction that determines whether both machines 2 and 3 are busy.
3. Write an LC-2
instruction that indicates none of the machines are busy.
4. Change machine 13
to 6.
Page 116, Problem 5.10. (1.1,1.2) The
last line of the program: The address should be 0100 0101 0110 1000, not 0100
0101 0110 0111.
Page 117, Problem 5.18. (1.1) Part 5,
second line: Replace "did not change any of the opcodes" with
"kept the number of opcodes at 16".
Page 117, Problem 5.19. (1.1) First
line:
The LC-2 ISA contains the instruction
LDR DR, BaseR, offset. After the LDR instruction is decoded, the
following operations (called microinstructions) are carried out to complete the
processing of the LDR instruction:
*Insert here lines 3 through 8 of the
problem statement*
*Replace the subsequent items 1 and 2
with the following*
1. The MOVE instruction is not really
necessary since it can be accomplished with a sequence of existing LC-2
instructions. What sequence of existing LC-2 instructions implements (also
called "emulates") MOVE R0,R1 ?
2. If the MOVE instruction were added
to the LC-2 ISA, what sequence of microinstructions, following the decode
operation, would emulate MOVE DR,SR ?
Page 117, Problem 5.20. (1.1) Restate
the problem as follows:
As stated in the text, we have saved
the JMP/JSR and JMPR/JSRR for Chapter 9. Those who can't wait can find the
description of these two instructions in Appendix A. Note that JMP and JSR have
exactly the same opcode, but their execution depends on the value of L. Why is
the case L=0 irrelevant to the LC-2 ISA? The opcodes JMPR and JSRR also have
exactly the same opcode. However, for JMPR/JSRR, the case L=0 is not
irrelevant. Why?
Page 118, Problem 5.21. (1.1) First
line: Change Section 3.5.5 to Section 5.3.5.
Page 129, Section 6.2.2. (1.1,1.2)
First sentence: the load instruction should be 0010
Page 131, Section 6.2.2. (1.1,1.2)
Line -4: Replace "the opcode 0100" with "the opcode 0010"
Page 136, Problem 6.7. (1.1,1.2) The
first line of machine code should be removed and all of the addresses should be
shifted down by one, so that x3001 becomes x3000 and so on.
Page 148, Problem 5.22. (2)
Replace : x3010 1110
1110 0011 0001
With :
x3010 1110 1100 0011 1111
Page 155, Problem 7.14. (1.1) We got
the 0 and the 1 wrong! So, change the wording in lines 5 and 6 so it reads:
If the strings are the same, the
program terminates with the value 1 in R5. If the strings are different, the
program terminates with the value 0 in R5.
Page 161, Section 8.2.2. (1.1,1.2)
Line 4 of code in middle of the page: The branch instruction should be
unconditional, so replace with BRnzp.
Page 163, Section 8.3.2/3. (1.1,1.2)
Both pieces of code on the page: The branch to NEXT_TASK should be
unconditional, so replace with BRnzp.
Page 164, Section 8.4. (1.1,1.2) Line
1: Replace "character!" with "character?"
Page 165, Figure 8.3. (1.1,1.2) Lines
11 and 20: Branches should be unconditional, so replace with BRnzp at both
locations.
Page 173, Section 9.1.2.
(1.1,1.2) Element 2, Append the following line:
Cross-reference
Table A.3 on pg. 449
Page 173, Figure 9.2. (1.1) The
figure should contain:
...
x0020 x0400
x0021 x0430
...
Page 176, Section 9.1.5. (1.1,1.2)
Line -10: Application is misspelled
Page 181, Figure 9.6. (1.1,1.2) Lines
x0F and x12 comments: replace '$' with 'x'
Page 181, Figure 9.6. (1.1,1.2) Line
36 (or x24 in the program):
Replace:
Message .FILL "Halting the
machine."
With: Message
.STRINGZ "Halting the machine."
page 187, line -9. (2)
Should read:
greater than LC+1+255 or less than LC+1-256,
Page 192, Problem 9.4. (1.1,1.2)
Replace:
BRNZP L2
With: BRnzp L2
Page 193, Problem 9.5. (1.1,1.2)
Replace:
DATA .BLKW 10 x0000
With: DATA
.BLKW 10
Replace:
BR G_TEXT
With: BRnzp G_TEXT
Page 194, Problem 9.6. (1.1,1.2) Code
at top of page, a period has taken the place of a comma, so:
Replace:
LD R4.OADDR
With: LD R4,OADDR
Page 194, Problem 9.9. (1.1,1.2)
Problem 5.20 is more appropriate for this chapter and will be inserted as the
last problem of the Chapter 9 problem set.
Page 196, Problem 7.20. (2)
Correct Part (a) to read:
.ORIG x5000
AND R0, R0, #0
ADD R0, R0, #15
ADD R0, R0, #6
STI R0, PTR
HALT
PTR .FILL x4000
.END
Page 196, Problem 7.21. (2)
Correct the program to read:
.ORIG x3000
AND R0, R0, #0
ADD R2, R0, #10
LD R1, MASK
LD R3, PTR1
LOOP LDR R4, R3, #0
AND R4, R4, R1
BRz NEXT
ADD R0, R0, #1
NEXT ADD R3, R3, #1
ADD R2, R2, #-1
BRp LOOP
STI R0, PTR2
HALT
MASK .FILL x8000
PTR1 .FILL x4000
PTR2 .FILL x5000
What does the program do?
Page 212, Figure 10.16. (1.1,1.2)
Reverse all decisions on the flowchart (i.e. replace yes with no and vice
versa)
Page 213, Figure 10.17. (1.1,1.2)
Replace:
ASCIIBUFF .BLKW 4, x0000
With: ASCIIBUFF
.BLKW 4
Page 217, Figure 10.19. (1.1,1.2) The
box that says Clear Stack should reference Figure 10.25, rather than 10.23
Page 218, Figure 10.20. (1.1,1.2) The
line BRz OpClear should reference Figure 10.25, rather than 10.23
Page 220, Figure 10.23. (1.1,1.2)
Replace:
StackBase .BLKW 9, x0000
With: StackBase
.BLKW 9
Page 222, Problem 10.8. (1.1) Part 3,
Replace ZYXWVUTSR with ZYXW.
Page 222, Problem 10.9. (1.1) Change
the problem statement to:
Describe, in your own words, how the
Multiply step of the OpMult algorithm in Figure 10.12 works. How many
instructions are executed to perform the Multiply step? Express your answer in
terms of n, the value of the multiplier. [Note: If an instruction executes 5
times, it contributes 5 to the total count.] Write a program fragment that
performs the Multiply step in fewer instructions if the value of the multiplier
is less than 25. How many instructions are executed now, in terms of n?
Page 235, Section 11.5.3. (1.1,1.2)
Replace the last sentence of the section, lines 6-8 with:
Since #define and #include are
preprocessor directives and not C statements, they are not terminated
by semicolons.
Page 235, Section 11.5.4. (1.1,1.2)
Line -8:
Replace: printf("43 plus 59 as a character is %d.", 43 + 59);
With: printf("43 plus 59 in decimal is
%d.", 43 + 59);
Page 239, Problem 11.9. (1.1) This
problem should read:
What happens if we change the
second-to-last line of the program in Figure 11.2 from:
printf("%d\n", counter);
to:
1. printf("%c\n", counter +
'A');
2. printf("%d\n%d\n",
counter, startPoint + counter);
Page 244, Section 12.2.1. (1.1,1.2)
First paragraph under "int"; third sentence:
The range of values for an int in the
LC-2 is incorrectly listed as -32,768 to -32,767. The correct values are
-32,768 to +32,767.
Page 249, Section 12.2.4. (1.1,1.2)
Line -2:
Replace: int
sevenBits = 0xA1234;
With: int sevenBits = 0x1234;
Page 249, Problem 9.19 (2)
The devices should have been labeled (1)-(4) instead of (a)-(d).
Page 250, Section 12.2.5. (1.1,1.2)
Second paragraph of section:
Replace: The
variable i is an integer variable and is stored at offset 3.
The variable start is also...
With: The variable counter is an
integer variable and is stored at offset 3. The variable startPoint is also...
Page 255, Figure 12.7. (1.1,1.2) 7th
line of code:
Replace:
STR R4, R6, #4 ; y = 3;
With: STR R4, R6,
#4 ; y = 5;
Page 259, Section 12.3.4. (1.1,1.2)
Second formula on page:
Replace: x = a * b
+ c * d / 2;
With: x = a * b + c * d / 4;
Page 285, Problem 10.11. (2)
Replace : contents of locations x00F1 and x00F2
With : contents of locations x01F1 and
x01F2
Page 285, Problem 10.14. (2)
Replace : If the buffer is full (i.e, if a character has
been stored in location x40FF)
With : If the buffer is full (i.e, if a
character has been stored in location x40FE)
Page 285, Problem 10.16. (2)
Replace : modified interrupt handler of Exercise 10.6
With : modified interrupt handler of
Exercise 10.15
Page 292, Figure 13.14. (1.1,1.2) 4th
line of code:
Replace: /*
Initial the result variable */
With: /* Initialize the result variable */
Page 294, Section 13.2.3. (1.1)
Disregard the last sentence of the second to last paragraph in this section
that begins as, "See Problem 15..." The while version of the program
behaves just like the do-while version.
Page 296, Section 13.4.1. (1.1,1.2)
Series expansion of pi: 4/(2n+1) at the end of the formula should
be 4/(2n-1)
Page 307, Problem 13.11. (Solution
Manual) The correct answer is:
#include<stdio>
main()
{
int a,b;
b = 10;
a = 5;
a = b - a;
b = a + a;
if (a > 0)
printf('1');
}
Page 308, Problem 13.15. (1.1) This
problem should be discarded. There is no difference in behavior between the
code in Figure 13.10 and Figure 13.16.
Page 332, Problem 14.9. (1.1) Part 2
should read: If the function food takes no arguments, then how many
local variables must it have?
Page 344, Problem 15.4. (1.1) The
program should echo not only the alphabetic characters, but ALSO the numeric
characters AND the space character.
Page 344-345, Problem 15.5. (1.1,1.2)
The problem is correct as stated, however, the variable names in the function IsDivisibleBy were
incorrectly used as chosen. The parameter "divisor" should instead be
"dividend" and the parameter "quotient" should instead be
"divisor".
Page 363, Problem 16.9. (1.1,1.2) The
function which is defined as "void M()" should be defined instead as
"int M()".
Page 384, Section 17.3.5. (1.1,1.2)
Line 7: (notice there are two changes)
Replace: either by
using work[3] or *(cptr + 4).
With: either by using word[3] or *(cptr + 3).
Page 427, Problem 19.4. (1.1) The
printed version of this problem contains an error. It is also quite a
challenging problem to solve. An easier (and correct) version of the problem is
included below, and the solution for this is provided in the solutions manual.
#include<stdio.h>
#define MAX 4
struct char_rec {
char ch;
struct char_rec *back;
};
main()
{
struct char_rec *ptr, pat[MAX+2];
int i = 1, j = 1;
printf("Pattern: ");
pat[1].back = pat;
ptr = pat;
while ((pat[i].ch = getchar( )) ! =
'\n') {
ptr[++i].back = ++ptr;
if (i > MAX) break;
}
while (j <= i)
printf("%d ", pat[j++].back
- pat);
/* Note the pointer arithmetic here:
subtraction of pointers to structures gives the number of structures between
addresses, not the number of memory locations */
}
Page 430, Table A.1. (1.1,1.2)
Replace xF402 with xFFFF.
Page 448, Appendix A. (1.1) Line
-5: Replace 192 with 224
Page 449, Table A.3. (1.1,1.2) The
table should read:
x22 PUTS Write a string pointed to by R0 to
the console. Each memory location contains one ASCII character.
x24 PUTS.P Write a string pointed to by R0
to the console. Each memory location contains two ASCII characters.
Page 452, Appendix B.1.1. (1.1,1.2)
Line -12: Replace 32-bit with 16-bit
Page 474, Figure C.2. (1.1,1.2) The
state machine figure fails to illustrate that LEA (state 11) sets the condition
codes. This is an error and should be noted that the LEA DOES set the condition
codes. Also, the arrow from state 19 to 34 should be labeled with a 0.
Page 480, Appendix C.4. (1.1,1.2)
Line 13:
Replace 111000 with 010000
Line 14:
Replace 111010 with 010010
Page 481, Appendix C.4. (1.1,1.2)
Line 5: Replace
J/111000 with J/010000
Line 8:
Replace 111000 with 010000
Line 9:
Replace 111010 with 010010
Last updated: 10.09.03
13:32 /mjs