p r e f a c e It is a pleasure to be writing a preface to
the second edition of this book. Three years have passed since the first edition
came out.We have received an enormous number of comments from students who have
studied the material in the book and from instructors who have taught from it.
Almost all have been very positive. It is gratifying to know that a lot of
people agree with our approach, and that this agreement is based on real
firsthand experience learning from it (in the case of students) or watching
students learn from it (in the case of instructors). The excitement displayed in their e-mail continues to be a
high for us. However, as we said in the preface to the
first edition, this book will always be a “work in progress.” Along with the
accolades, we have received some good advice on howto make it better.We thank
you for that.We have also each taught the course two more times since the first
edition came out, and that, too, has improved our insights into what we think we
did right and what needed improvement. The result has been a lot of changes in
the second edition, while hopefully maintaining the essence of what we had before. How well we have succeeded we hope to soon learn
from you. Major Changes to the First Edition The LC-3 One of the more obvious changes in the second
edition is the replacement of the LC-2 with the LC-3. We insisted on keeping the
basic concept of the LC-2: a rich ISA that can be described in a few pages, and
hopefully mastered in a short time.We kept the 16-bit instruction and 4-bit
opcode. One of our students pointed out that the subroutine return instruction
(RET) was just a special case of LC-2’s JMPR instruction, so we eliminated RET
as a separate opcode. The LC-3 specifies only 15 opcodes—and leaves one for future use (perhaps,
the third edition!). We received a lot of push-back on the
PC-concatenate addressing mode, particularly for branches. The addressing mode
had its roots in the old PDP-8 of the mid-1960s.Amajor problem with it comes up
when an instruction on one page wants to dereference the next (or previous)
page. This has been a major hassle, particularly for forward branches close to a
page boundary. A lot of people have asked us to use the more modern PC+offset,
and we agreed.We have replaced all uses of PC’offset with
PC+SEXT(offset). We incorporated other changes in the LC-3.
Stacks now grow toward 0, in keeping with current conventional practice. The
offset in LDR/STR is now a signed value, so addresses can be computed plus or minus
a base address. The opcode 1101 is not specified. The JSR/JMP opcodes have
been reorganized slightly. Finally, we expanded the condition codes to a 16-bit
processor status register (PSR) that includes a privilege mode and a priority
level. As in the first edition, Appendix A specifies the LC-3
completely. Additional Material Although no chapter in the book has remained
untouched, some chapters have been changed more than others.We added discussions
to Chapter 1 on the nature and importance of abstraction and the interplay of
hardware and software because it became clear that these points needed to be
made explicit. We added a full section to Chapter 3 on finite state control and
its implementation as a sequential switching circuit because we believe the
concept of state and finite state control are among the most important concepts
a computer science or engineering student encounters. We feel it is also useful
to the understanding of the von Neumann model of execution discussed in Chapter
4.We added a section to Chapter 4 giving a glimpse of the underlying
microarchitecture of the LC-3, which is spelled out in all its detail in the
overhauled Appendix C.We were told by more than one reader that Chapter 5 was
too terse.We added little new material, but lots of figures and explanations
that hopefully make the concepts clearer.We also added major new sections on interrupt-driven I/O to Chapters 8
and 10. Just as in the first edition, Chapters 11 through 14 introduce the
C programming language. Unlike the first edition, these chapters are more
focused on the essential aspects of the language useful to a beginning
programmer. Specialized features, for example the C switch construct, are
relegated to the ends of the chapters (or to Appendix D), out of the main line
of the text. All of these chapters include more examples than the first edition.
The second edition also places a heavier emphasis on “how to program” via
problem-solving examples that demonstrate how newly introduced C constructs can
be used in C programming. In Chapter 14, students are exposed to a new LC-3
calling convention that more closely reflects the calling convention used by
real systems. Chapter 15 contains a deeper treatment of testing and debugging.
Based on our experiences teaching the introductory course, we have decided to
swap the order of the chapter on recursion with the chapter on pointers and
arrays. Moving recursion later (now Chapter 17) in the order of treatment allows
students to gain more experience with basic programming concepts before they
start programming recursive functions. The Simulator Brian Hartman has updated the simulator that
runs on Windows to incorporate the changes to the LC-3. AshleyWise has written
an LC-3 simulator that runs on UNIX. Both have incorporated interrupt-driven I/O
into the simulator’s functionality. We believe strongly that there is no
substitute for hands-on practice testing one’s knowledge. With the addition of
interrupt-driven I/O to the simulator, the student can now interrupt an
executing program by typing a key on the keyboard and invoke an interrupt service routine. Alternate Uses of the Book We wrote the book as a textbook for a
freshman introduction to computing. We strongly believe, as stated more
completely in the preface to our first edition, that our motivated bottom-up
approach is the best way for students to learn the fundamentals of computing. We
have seen lots of evidence that suggests that in general, students who
understand the fundamentals of how the computer works are better able to grasp
the stuff that they encounter later, including the high-level programming
languages that they must work in, and that they can learn the rules of these
programming languages with far less memorizing because everything makes sense.
For us, the best use of the book is a one-semester freshman course for
particularly motivated students, or a two-semester sequence where the pace is
tempered. If you choose to go the route of a one-semester course heavy on
high-level language programming, you probably want to leave out the material on
sequential machines and interrupt-driven I/O. If you choose to go the
onesemester route heavy on the first half of the book, you probably want to leave out much of Chapters 15, 17, 18,
and 19. We have also seen the book used effectively in each
of the following environments: Two Quarters, Freshman Course In some sense this is the best use of the
book. In the first quarter, Chapters 1 through 10 are covered; in the second
quarter, Chapters 11 through 19. The pace is brisk, but the entire book can be covered in
two academic quarters. One-Semester Second Course The book has been used successfully as a
second course in computing, after the student has spent the first course with a
high-level programming language. The rationale is that after exposure to
high-level language programming in the first course, the second course should
treat at an introductory level digital logic, basic computer organization, and
assembly language programming. Most of the semester is spent on Chapters 1
through 10, with the last few weeks spent on a few topics from Chapters 11
through 19, showing how some of the magic from the students’ first course can
actually be implemented. Functions, activation records, recursion, pointer
variables, and some elementary data structures are typically the topics that
get covered. A Sophomore-Level Computer Organization Course The book has been used to delve deeply into
computer implementation in the sophomore year. The semester is spent in Chapters
1 through 10, sometimes culminating in a thorough study of Appendix C, which
provides the complete microarchitecture of a microprogrammed LC-3. We note,
however, that some very important ideas in computer architecture are not covered
here, most notably cache memory, pipelining, and virtual memory. We agree that
these topics are very important to the education of a computer scientist or
computer engineer, but we feel these topics are better suited to a senior course
in computer architecture and design. This book is not intended for that
purpose. Acknowledgments Our book continues to benefit greatly from
important contributions of many, many people. We particularly want to acknowledge Brian Hartman
and Matt Starolis. Brian Hartman continues to be a very important part of this work,
both for the great positive energy he brings to the table and for his technical
expertise. He is now out of school more than three years and remains committed
to the concept. He took the course the first year it was offered at Michigan
(Winter term, 1996), TAed it several times as an undergraduate student, and
wrote the first LC-2 simulator for Windows while he was working on his master’s
degree. He recently upgraded the Windows simulator to incorporate the new LC-3.
Matt Starolis took the freshman course at UT two years ago and
TAed it as a junior last fall. He, too, has been very important to us getting
out this second edition. He has been both critic of our writing and helpful
designer of many of the figures. He also updated the tutorials for the
simulators, which was necessary in order to incorporate the new characteristics
of the LC-3. When something needed to be done, Matt volunteered to do it. His
enthusiasm for the course and the book has been a pleasure. With more than 100 adopters now, we regularly
get enthusiastic e-mail with suggestions from professors from all over the
world. Although we realize we have undoubtedly forgotten some, we would at least
like to thank Professors Vijay Pai, Rice; Richard Johnson, Western New Mexico;
Tore Larsen, Tromso; Greg Byrd, NC State; Walid Najjar, UC Riverside; Sean
Joyce, Heidelberg College; James Boettler, South Carolina State; Steven
Zeltmann, Arkansas; Mike McGregor, Alberta; David Lilja, Minnesota; Eric Thompson, Colorado, Denver; and Brad Hutchings,
Brigham Young. Between the two of us, we have taught the
course four more times since the first edition came out, and that has produced a
new enthusiastic group of believers, both TAs and students. Kathy Buckheit,
Mustafa Erwa, Joseph Grzywacz, Chandresh Jain, Kevin Major, Onur Mutlu,
Moinuddin Qureshi, Kapil Sachdeva, Russell Schreiber, Paroma Sen, Santhosh
Srinath, Kameswar Subramaniam, David Thompson, Francis Tseng, Brian Ward, and
Kevin Woley have all served as TAs and have demonstrated a commitment to helping
students learn that can only be described aswonderful. Linda Bigelow, Matt
Starolis, and Lester Guillory all took the course as freshmen, and two years later they were among the most enthusiastic TAs the course
has known. Ashley Wise developed the Linux version of
the LC-3 simulator. Ajay Ladsaria ported the LCC compiler to generate LC-3 code.
Gregory Muthler and Francesco Spadini enthusiastically provided critical feedback on drafts of the chapters in the second
half. Kathy Buckheit wrote introductory tutorials
to help students use the LC-2 simulator because she felt it
was necessary. Several other faculty members at The
University of Texas have used the book and shared their insights with us: Tony
Ambler, Craig Chase, Mario Gonzalez, and Earl Swartzlander in ECE, and Doug
Burger, Chris Edmundson, and Steve Keckler in CS. We thank them. We continue to celebrate the commitment displayed by our editors, Betsy Jones and Michelle
Flomenhoft. As was the case with the first edition, our
book has benefited from extensive reviews provided by faculty members from many
universities. We thank Robert Crisp, Arkansas; Allen Tannenbaum, Georgia Tech;
Nickolas Jovanovic, Arkansas–Little Rock; Dean Brock, North Carolina–Asheville;
Amar Raheja, Cal State–Pomona; Dayton Clark, Brooklyn College; William Yurcik,
Illinois State; Jose Delgado-Frias, Washington State; Peter Drexel, Plymouth
State; Mahmoud Manzoul, Jackson State; Dan Connors, Colorado; Massoud Ghyam,
Southern Cal; John Gray, UMass–Dartmouth; John Hamilton, Auburn; Alan Rosenthal, Toronto; and Ron Taylor,
Wright State. Finally, there are those who have contributed
in many different and often unique ways. Without listing their individual
contributions, we simply list them and say thank you. Amanda, Bryan, and Carissa
Hwu, Mateo Valero, Rich Belgard, Janak Patel, Matthew Frank, Milena Milenkovic,
Lila Rhoades, Bruce Shriver, Steve Lumetta, and Brian Evans. Sanjay would like to thank Ann Yeung for all her love
and support. A Final Word It is worth repeating our final words from
the preface to the first edition: We are mindful that the current version of
this book will always be a work in progress, and we welcome your comments on any
aspect of it. You can reach us by e-mail at patt@ece.utexas.edu and sjp@crhc.uiuc.edu.
We hope you will. Yale N. Patt Sanjay J. Patel May, 2003 |