lcc, A Retargetable Compiler for ANSI C

1st Printing Errata

In the lists below, line +n and line -n refer to the nth line from the top and bottom of the indicated page. Additional errors are listed in the errata for the 2nd printing.

Page 2, line +18: missing `last'; the sentence should read `...the next link on the last definition is omitted.'

Page 17, line -2: remove the semicolon.

Page 24, line -13: Change `NEW(a[i++])' to `NEW(a[i++], PERM)'.

Page 48, line -16: missing `by'; the sentence should read `..., the string returned by vtoa.'

Page 78, line +11: `19 functions' should be `18 functions.'

Page 79, line -7: `19 interface functions' should be `18 interface functions.'

Page 87, line -5: `zero' should be `one'; the sentence should read `It should be one if the hardware leaves these operations to library routines.'

Page 88, line -2: missing `is'; the sentence should read `If left_to_right is zero, ...'

Page 99, line -5: extraneous `it'; the sentence should read `..., which the back end reads and translates to target code.'

Page 131, lines +9..+10: `+' operators should be `*'; the righthand sides of the last two derivation steps should read

a + b * c Y
a + b * c epsilon

where epsilon denotes the lowercase Greek symbol by the same name.

Page 170, lines -6..-5: extraneous `used'; the sentence should read `... describes the technique as it is used in lcc.'

Page 186, line +13: extraneous `to'; the sentence should read `... and lets call do most of the work:'

Page 202, lines +4 and +8: retype should be cast.

Page 231, line +13: `where n >= 4' should be `where n >= 1.'

Page 256, line -4: the if statement should read

if (istypename(t, tsym) && type == 0 && sign == 0 && size == 0) {

Page 322, line +17: the if statement should read `if (forest && forest->syms[0])'.

Page 323, line +6, +15: insert `if (depth++ == 0) reset();' after line 6, and insert `depth--;' after line 15. depth is a static integer declared in dag.c.

Page 323, line +16: Add the sentence `Exercise 12.15 explains the purpose of the static integer depth and the call to reset.'

Page 342, line +12: the declaration should read

int i; unsigned k = cp->u.swtch.values[0];

Page 342, line +14..+15: the nested loops should read

for (i = 0; i < cp->u.swtch.size; i++, k++) {    for ( ; k < (unsigned)cp->u.swtch.values[i]; k++)

Page 351, line -1: Add exercise 12.15:

12.15 The code for <AND> begins by calling reset if depth is zero and incrementing depth, and this case ends by decrementing depth. The case for OR does the same. Thus, depth counts the number of nested AND or OR operators. The call to reset is needed for the same reason that it is needed in the case for COND, as explained on page 326. Show that without calling reset, lcc generates incorrect code for the assignment

x[i] = (n || (n=i), n);

Calling reset has no effect on the usual use of && and || as illustrated in Figure 12.3; explain why.

Page 371, line +3: `hexidecimal' should be `hexadecimal'.

Page 373, lines +15..+16: missing `it'; the sentence should read `..., so it emits one BURM into each of ...'

Page 386, line +21: the code should read

p->x.kids[0] = p->x.kids[1] = p->x.kids[2] = NULL;

Page 400, line +12: the if statement should read

if (r != q->syms[RX] && !q->syms[RX]->x.wildcard) {

Page 412, line +2: `unsigned integers' should be `integer registers'.

Page 422, line +18: the first line of the if statement should read

if (ri != NULL && ri->x.lastuse

Page 423, lines +13..+14: replace these lines with

Symbol tmp; Node p = r->x.lastuse;

Page 423, lines +23..+25: remove the extraneous braces.

Page 423, line -10: insert the assignment

tmp = newtemp(AUTO, optype(p->op));

before the call to genspill. (The changes on page 423 were made to accommodate an added assert(p), which isn't shown in the book.)

Page 426, line -1: change the declaration to

struct node x, *q = *pp;

Page 427, lines +6..+10: change these lines to

if (k == n) { *pp = p->x.kids[n]; 	x = *p; 	(IR->x.target)(&x); } return k + 1; 

Page 427, line -10: change `update.' to `update, and x confines the change to the reload.'

Page 463, line -19: `code generator' should be `assembler'.

Page 512, line -4: this line should read

rtarget(p->kids[1], 0, intreg[ESI]);

Page 534, line 7: change `research.att.com' to `ftp.cs.princeton.edu in pub/lcc/contrib'.

Thanks to Nelson Beebe, Franklin Chen, Amnon Cohen, Russ Cox, Guy Laden, Jonathan Litt, Paul Mattal, Scott Nicholas, Richard O'Keefe, Norman Ramsey, Duane Sand, Bernie Solomon, and Gary Tyson for finding some of these errors.