100% found this document useful (8 votes)
144 views

Introduction to Computing Systems: From Bits & Gates to C & Beyond 3rd Edition Yale Patt - eBook PDFpdf download

The document is an overview of the book 'Introduction to Computing Systems: From Bits & Gates to C/C++ & Beyond' by Yale N. Patt and Sanjay J. Patel, detailing its content and structure. It includes links to download the eBook and other related titles. The book covers foundational concepts in computing, including digital logic, data types, and programming, aimed at providing a comprehensive understanding of computing systems.

Uploaded by

bucosruzan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (8 votes)
144 views

Introduction to Computing Systems: From Bits & Gates to C & Beyond 3rd Edition Yale Patt - eBook PDFpdf download

The document is an overview of the book 'Introduction to Computing Systems: From Bits & Gates to C/C++ & Beyond' by Yale N. Patt and Sanjay J. Patel, detailing its content and structure. It includes links to download the eBook and other related titles. The book covers foundational concepts in computing, including digital logic, data types, and programming, aimed at providing a comprehensive understanding of computing systems.

Uploaded by

bucosruzan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Introduction to Computing Systems: From Bits &

Gates to C & Beyond 3rd Edition Yale Patt -


eBook PDF download

https://ebooksecure.com/download/introduction-to-computing-
systems-from-bits-gates-to-c-beyond-ebook-pdf/

Download more ebook from https://ebooksecure.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebooksecure.com
to discover even more!

(eBook PDF) Introduction to Information Systems 3rd


Edition

http://ebooksecure.com/product/ebook-pdf-introduction-to-
information-systems-3rd-edition/

Introduction to Computing 1st Edition David A. Joyner -


eBook PDF

https://ebooksecure.com/download/introduction-to-computing-ebook-
pdf/

(eBook PDF) Processes, Systems, and Information: An


Introduction to MIS 3rd Edition

http://ebooksecure.com/product/ebook-pdf-processes-systems-and-
information-an-introduction-to-mis-3rd-edition/

Introduction to Criminal Justice: Systems, Diversity,


and Change 3rd Edition (eBook PDF)

http://ebooksecure.com/product/introduction-to-criminal-justice-
systems-diversity-and-change-3rd-edition-ebook-pdf/
(eBook PDF) Introduction to Information Systems:
People, Technology and Processes 3rd Edition

http://ebooksecure.com/product/ebook-pdf-introduction-to-
information-systems-people-technology-and-processes-3rd-edition/

(Textbook) Introduction to Information Systems 6th


Edition

http://ebooksecure.com/product/textbook-introduction-to-
information-systems-6th-edition/

(eBook PDF) Human Physiology From Cells to Systems 9th


Edition

http://ebooksecure.com/product/ebook-pdf-human-physiology-from-
cells-to-systems-9th-edition/

(eBook PDF) C++ Programming: From Problem Analysis to


Program Design 7th

http://ebooksecure.com/product/ebook-pdf-c-programming-from-
problem-analysis-to-program-design-7th/

(Original PDF) C++ Programming From Problem Analysis to


Program Design 8th

http://ebooksecure.com/product/original-pdf-c-programming-from-
problem-analysis-to-program-design-8th/
third edition

introduction
to computing
systems
from bits & gates to
C/C++ & beyond

yale n. patt
sanjay j. patel
introduction to
computing systems
third edition

introduction to
computing systems
from bits & gates to C/C++ & beyond

Yale N. Patt
The University of Texas at Austin

Sanjay J. Patel
University of Illinois at Urbana-Champaign
INTRODUCTION TO COMPUTING SYSTEMS: FROM BITS & GATES TO C/C++ & BEYOND, THIRD EDITION

Published by McGraw-Hill Education, 2 Penn Plaza, New York, NY 10121. Copyright 2020 c by McGraw-Hill Education. All rights
reserved. Printed in the United States of America. Previous editions 2004,
c and 2001. No part of this publication may be reproduced
or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written consent of McGraw-Hill
Education, including, but not limited to, in any network or other electronic storage or transmission, or broadcast for distance learning.

Some ancillaries, including electronic and print components, may not be available to customers outside the United States.

This book is printed on acid-free paper.

1 2 3 4 5 6 7 8 9 LCR 24 23 22 21 20 19

ISBN 978-1-260-15053-7 (bound edition)


MHID 1-260-15053-4 (bound edition)
ISBN 978-1-260-42474-4 (loose-leaf edition)
MHID 1-260-42474-X (loose-leaf edition)

Executive Portfolio Manager: Suzy Bainbridge


Product Developer: Heather Ervolino
Senior Marketing Manager: Shannon O’Donnell
Content Project Manager: Jeni McAtee
Buyer: Sandy Ludovissy
Designer: David Hash
Content Licensing Specialist: Melissa Homer
Cover Image: Front Cover Computing art Yale c N. Patt; Abstract image in green, orange and yellow Design
c Pics/Tim Antoniuk;
Abstract image in orange, green and yellow Design
c Pics/Tim Antoniuk; Computer laptops on a blue abstract background loops7/
c
Getty Images; Illustration of streams of binary code Shutterstock/Tavarius
c
Compositor: Aptara R
, Inc.

All credits appearing on page or at the end of the book are considered to be an extension of the copyright page.

Library of Congress Cataloging-in-Publication Data


Names: Patt, Yale N., author. Patel, Sanjay J., author.
Title: Introduction to computing systems : from bits & gates to c/c++ &
beyond / Yale N. Patt, The University of Texas at Austin, Sanjay J. Patel,
University of Illinois at Urbana-Champaign.
Description: Third edition. New York, NY : McGraw-Hill, 2020.
Identifiers: LCCN 2018050089 ISBN 9781260150537 (acid-free paper) ISBN
1260150534 (acid-free paper)
Subjects: LCSH: Computer science. C (Computer program language)
Classification: LCC QA76 .P367 2019 DDC 004–dc23 LC record available at
https://lccn.loc.gov/2018050089

The Internet addresses listed in the text were accurate at the time of publication. The inclusion of a website does not indicate an endorse-
ment by the authors or McGraw-Hill Education, and McGraw-Hill Education does not guarantee the accuracy of the information presented
at these sites.

mheducation.com/highered
To the memory of my parents,
Abraham Walter Patt A"H and Sarah Clara Patt A"H,
who taught me to value “learning”
even before they taught me to ride a bicycle.

To my loving family,
Amita, Kavi, and Aman.
Contents

Preface xv 2.4 Conversion Between Binary and Decimal 31


2.4.1 Binary to Decimal Conversion 31
2.4.2 Decimal to Binary Conversion 32
2.4.3 Extending Conversion to Numbers with
1 Welcome Aboard 1 Fractional Parts 33
1.1 What We Will Try to Do 1
2.5 Operations on Bits—Part I: Arithmetic 34
1.2 How We Will Get There 1
2.5.1 Addition and Subtraction 34
1.3 Two Recurring Themes 3
2.5.2 Sign-Extension 36
1.3.1 The Notion of Abstraction 3
2.5.3 Overflow 36
1.3.2 Hardware vs. Software 5
2.6 Operations on Bits—Part II: Logical
1.4 A Computer System 7
Operations 38
1.4.1 A (Very) Little History for a (Lot)
2.6.1 A Logical Variable 38
Better Perspective 8
2.6.2 The AND Function 38
1.4.2 The Parts of a Computer
2.6.3 The OR Function 39
System 10
2.6.4 The NOT Function 40
1.5 Two Very Important Ideas 11
2.6.5 The Exclusive-OR Function 40
1.6 Computers as Universal
2.6.6 DeMorgan’s Laws 41
Computational Devices 12
2.6.7 The Bit Vector 42
1.7 How Do We Get the Electrons to Do
2.7 Other Representations 43
the Work? 14
2.7.1 Floating Point Data Type (Greater Range,
1.7.1 The Statement of the Problem 14
Less Precision) 43
1.7.2 The Algorithm 16
2.7.2 ASCII Codes 47
1.7.3 The Program 16
2.7.3 Hexadecimal Notation 48
1.7.4 The ISA 17
Exercises 49
1.7.5 The Microarchitecture 18
1.7.6 The Logic Circuit 19
1.7.7 The Devices 19
Exercises 20 3 Digital Logic Structures 59
3.1 The Transistor 59
3.2 Logic Gates 61
3.2.1 The NOT Gate (Inverter) 61
2 Bits, Data Types, 3.2.2 OR and NOR Gates 62
and Operations 25 3.2.3 Why We Can’t Simply Connect P-Type
2.1 Bits and Data Types 25 to Ground 64
2.1.1 The Bit as the Unit of Information 25 3.2.4 AND and NAND Gates 65
2.1.2 Data Types 26 3.2.5 Gates with More Than Two Inputs 66
2.2 Integer Data Types 26 3.3 Combinational Logic Circuits 67
2.2.1 Unsigned Integers 26 3.3.1 Decoder 67
2.2.2 Signed Integers 27 3.3.2 Mux 68
2.3 2’s Complement Integers 29 3.3.3 A One-Bit Adder (a.k.a. a Full Adder) 69
viii Contents

3.3.4 The Programmable Logic 5.1.3 The Instruction Set 147


Array (PLA) 71 5.1.4 Opcodes 149
3.3.5 Logical Completeness 72 5.1.5 Data Types 149
3.4 Basic Storage Elements 73 5.1.6 Addressing Modes 150
3.4.1 The R-S Latch 73 5.1.7 Condition Codes 150
3.4.2 The Gated D Latch 74 5.2 Operate Instructions 151
3.5 The Concept of Memory 75 5.2.1 ADD, AND, and NOT 151
3.5.1 Address Space 75 5.2.2 Immediates 152
3.5.2 Addressability 76 5.2.3 The LEA Instruction (Although Not Really
3.5.3 A 22 -by-3-Bit Memory 76 an Operate) 154
3.6 Sequential Logic Circuits 78 5.3 Data Movement Instructions 155
3.6.1 A Simple Example: The 5.3.1 PC-Relative Mode 156
Combination Lock 79 5.3.2 Indirect Mode 158
3.6.2 The Concept of State 80 5.3.3 Base+offset Mode 159
3.6.3 The Finite State Machine and Its 5.3.4 An Example 160
State Diagram 82 5.4 Control Instructions 161
3.6.4 The Synchronous Finite 5.4.1 Conditional Branches 162
State Machine 85 5.4.2 Two Methods of Loop Control 165
3.6.5 The Clock 86 5.4.3 The JMP Instruction 169
3.6.6 Example: A Danger Sign 87 5.4.4 The TRAP Instruction 169
3.7 Preview of Coming Attractions: The Data Path 5.5 Another Example: Counting Occurrences
of the LC-3 93 of a Character 170
Exercises 95 5.6 The Data Path Revisited 173
5.6.1 Basic Components of the
Data Path 175
4 The von Neumann Model 121 5.6.2 The Instruction Cycle Specific
4.1 Basic Components 121 to the LC-3 176
4.1.1 Memory 122 Exercises 177
4.1.2 Processing Unit 123
4.1.3 Input and Output 124
4.1.4 Control Unit 125 6 Programming 203
4.2 The LC-3: An Example von 6.1 Problem Solving 203
Neumann Machine 125 6.1.1 Systematic Decomposition 203
4.3 Instruction Processing 127 6.1.2 The Three Constructs: Sequential,
4.3.1 The Instruction 127 Conditional, Iterative 204
4.3.2 The Instruction Cycle (NOT the 6.1.3 LC-3 Control Instructions to Implement
Clock Cycle!) 130 the Three Constructs 205
4.3.3 Changing the Sequence of 6.1.4 The Character Count Example from
Execution 132 Chapter 5, Revisited 206
4.3.4 Control of the Instruction Cycle 134 6.2 Debugging 210
4.3.5 Halting the Computer (the TRAP 6.2.1 Debugging Operations 211
Instruction) 136 6.2.2 Use of an Interactive Debugger 212
4.4 Our First Program: A Multiplication Exercises 220
Algorithm 137
Exercises 139
7 Assembly Language 231
7.1 Assembly Language Programming—Moving
5 The LC-3 145 Up a Level 231
5.1 The ISA: Overview 145 7.2 An Assembly Language Program 232
5.1.1 Memory Organization 146 7.2.1 Instructions 233
5.1.2 Registers 146 7.2.2 Pseudo-Ops (Assembler Directives) 236
Contents ix

7.2.3 Example: The Character Count Example 9.2 Input/Output 317


of Section 5.5, Revisited Again! 238 9.2.1 Some Basic Characteristics
7.3 The Assembly Process 240 of I/O 317
7.3.1 Introduction 240 9.2.2 Input from the Keyboard 320
7.3.2 A Two-Pass Process 240 9.2.3 Output to the Monitor 322
7.3.3 The First Pass: Creating the 9.2.4 A More Sophisticated Input
Symbol Table 241 Routine 325
7.3.4 The Second Pass: Generating the 9.2.5 Implementation of Memory-Mapped
Machine Language Program 242 I/O, Revisited 326
7.4 Beyond the Assembly of a Single Assembly 9.3 Operating System Service Routines
Language Program 243 (LC-3 Trap Routines) 327
7.4.1 The Executable Image 244 9.3.1 Introduction 327
7.4.2 More than One Object File 244 9.3.2 The Trap Mechanism 329
Exercises 245 9.3.3 The TRAP Instruction 330
9.3.4 The RTI Instruction: To Return
Control to the Calling
8 Data Structures 263 Program 331
8.1 Subroutines 263 9.3.5 A Summary of the Trap Service
8.1.1 The Call/Return Mechanism 265 Routine Process 331
8.1.2 JSR(R)—The Instruction That Calls 9.3.6 Trap Routines for Handling I/O 333
the Subroutine 266 9.3.7 A Trap Routine for Halting
8.1.3 Saving and Restoring Registers 267 the Computer 335
8.1.4 Library Routines 269 9.3.8 The Trap Routine for Character Input
8.2 The Stack 273 (One Last Time) 336
8.2.1 The Stack—An Abstract Data Type 273 9.3.9 PUTS: Writing a Character String to
8.2.2 Two Example Implementations 273 the Monitor 338
8.2.3 Implementation in Memory 274 9.4 Interrupts and Interrupt-Driven I/O 339
8.2.4 The Complete Picture 278 9.4.1 What Is Interrupt-Driven I/O? 339
8.3 Recursion, a Powerful Technique When Used 9.4.2 Why Have Interrupt-Driven I/O? 340
Appropriately 280 9.4.3 Two Parts to the Process 341
8.3.1 Bad Example Number 1: Factorial 280 9.4.4 Part I: Causing the Interrupt to
8.3.2 Fibonacci, an Even Worse Occur 341
Example 285 9.4.5 Part II: Handling the Interrupt
8.3.3 The Maze, a Good Example 288 Request 344
8.4 The Queue 294 9.4.6 An Example 347
8.4.1 The Basic Operations: Remove from 9.4.7 Not Just I/O Devices 349
Front, Insert at Rear 295 9.5 Polling Revisited, Now That We Know
8.4.2 Wrap-Around 295 About Interrupts 350
8.4.3 How Many Elements Can We Store 9.5.1 The Problem 350
in a Queue? 296 9.5.2 The Solution 351
8.4.4 Tests for Underflow, Overflow 297 Exercises 352
8.4.5 The Complete Story 298
8.5 Character Strings 300
Exercises 304
10 A Calculator 379
10.1 Data Type Conversion 380
9 I/O 313 10.1.1 Example: A Bogus Program:
9.1 Privilege, Priority, and the Memory 2 + 3 = e 381
Address Space 314 10.1.2 Input Data (ASCII to Binary) 381
9.1.1 Privilege and Priority 314 10.1.3 Display Result (Binary
9.1.2 Organization of Memory 316 to ASCII) 385
x Contents

10.2 Arithmetic Using a Stack 387 12.3.7 Logical Operators 438


10.2.1 The Stack as Temporary Storage 387 12.3.8 Increment /Decrement Operators 439
10.2.2 An Example 388 12.3.9 Expressions with Multiple
10.2.3 OpAdd, OpMult, and OpNeg 389 Operators 441
10.3 The Calculator 395 12.4 Problem Solving Using Operators 441
10.3.1 Functionality 395 12.5 Tying It All Together 444
10.3.2 Code 396 12.5.1 Symbol Table 444
Exercises 402 12.5.2 Allocating Space for Variables 445
12.5.3 A Comprehensive Example 447
12.6 Additional Topics 449
12.6.1 Variations of the Basic Types 450
11 Introduction to C/C++ 12.6.2 Literals, Constants, and Symbolic
Programming 405 Values 451
11.1 Our Objective 405 12.6.3 Additional C Operators 452
11.2 Bridging the Gap 406 12.7 Summary 453
11.3 Translating High-Level Language Exercises 453
Programs 410
11.3.1 Interpretation 410
11.3.2 Compilation 411 13 Control Structures 457
11.3.3 Pros and Cons 411 13.1 Introduction 457
11.4 The C/C++ Programming Languages 411 13.2 Conditional Constructs 457
11.4.1 The Origins of C and C++ 411 13.2.1 The if Statement 458
11.4.2 How We Will Approach C 13.2.2 The if-else Statement 460
and C++ 412 13.3 Iteration Constructs 464
11.4.3 The Compilation Process 413 13.3.1 The while Statement 464
11.4.4 Software Development 13.3.2 The for Statement 466
Environments 415 13.3.3 The do-while Statement 471
11.5 A Simple Example in C 415 13.4 Problem Solving Using Control
11.5.1 The Function main 415 Structures 472
11.5.2 Formatting, Comments, and Style 417 13.4.1 Problem 1: Approximating the
11.5.3 The C Preprocessor 418 Value of 𝜋 472
11.5.4 Input and Output 419 13.4.2 Problem 2: Finding Prime Numbers
11.6 Summary 422 Less Than 100 474
Exercises 422 13.4.3 Problem 3: Analyzing an E-mail
Address 477
13.5 Additional C Control Structures 480
13.5.1 The switch Statement 480
12 Variables and Operators 425 13.5.2 The break and continue
12.1 Introduction 425
Statements 482
12.2 Variables 425
13.5.3 An Example: Simple
12.2.1 Four Basic Data Types 426
Calculator 482
12.2.2 Choosing Identifiers 429
13.6 Summary 484
12.2.3 Scope: Local vs. Global 429
Exercises 484
12.2.4 More Examples 431
12.3 Operators 432
12.3.1 Expressions and Statements 433
12.3.2 The Assignment Operator 433 14 Functions 491
12.3.3 Arithmetic Operators 434 14.1 Introduction 491
12.3.4 Order of Evaluation 435 14.2 Functions in C 492
12.3.5 Bitwise Operators 436 14.2.1 A Function with a Parameter 492
12.3.6 Relational Operators 437 14.2.2 Example: Area of a Ring 495
Contents xi

14.3 Implementing Functions in C 497 16.3.6 Problem Solving: Insertion Sort 556
14.3.1 Run-Time Stack 497 16.3.7 Common Pitfalls with Arrays in C 559
14.3.2 Getting It All to Work 500 16.3.8 Variable-Length Arrays 559
14.3.3 Tying It All Together 505 16.3.9 Multidimensional Arrays in C 561
14.4 Problem Solving Using Functions 507 16.4 Summary 563
14.4.1 Problem 1: Case Conversion 507 Exercises 563
14.4.2 Problem 2: Pythagorean Triples 508
14.5 Summary 510
Exercises 511 17 Recursion 569
17.1 Introduction 569
17.2 What Is Recursion? 570
15 Testing and Debugging 517 17.3 Recursion vs. Iteration 571
15.1 Introduction 517 17.4 Towers of Hanoi 572
15.2 Types of Errors 518 17.5 Fibonacci Numbers 576
15.2.1 Syntactic Errors 519 17.6 Binary Search 581
15.2.2 Semantic Errors 519 17.7 Escaping a Maze 583
15.2.3 Algorithmic Errors 521 17.8 Summary 586
15.2.4 Specification Errors 522 Exercises 587
15.3 Testing 523
15.3.1 Black-Box Testing 524
15.3.2 White-Box Testing 524 18 I/O in C 593
15.4 Debugging 525 18.1 Introduction 593
15.4.1 Ad Hoc Techniques 526 18.2 The C Standard Library 593
15.4.2 Source-Level Debuggers 526 18.3 I/O, One Character at a Time 594
15.5 Programming for Correctness 528 18.3.1 I/O Streams 594
15.5.1 Nailing Down the Specifications 529 18.3.2 putchar 595
15.5.2 Modular Design 529 18.3.3 getchar 595
15.5.3 Defensive Programming 530 18.3.4 Buffered I/O 595
15.6 Summary 531 18.4 Formatted I/O 597
Exercises 532 18.4.1 printf 597
18.4.2 scanf 599
18.4.3 Variable Argument Lists 601
16 Pointers and Arrays 537 18.5 I/O from Files 602
16.1 Introduction 537 18.6 Summary 605
16.2 Pointers 537 Exercises 605
16.2.1 Declaring Pointer Variables 539
16.2.2 Pointer Operators 540
16.2.3 Passing a Reference Using 19 Dynamic Data Structures in C 607
Pointers 541 19.1 Introduction 607
16.2.4 Null Pointers 543 19.2 Structures 608
16.2.5 Demystifying the Syntax 543 19.2.1 typedef 610
16.2.6 An Example Problem Involving 19.2.2 Implementing Structures in C 611
Pointers 544 19.3 Arrays of Structures 611
16.3 Arrays 545 19.4 Dynamic Memory Allocation 614
16.3.1 Declaring and Using Arrays 546 19.4.1 Dynamically Sized Arrays 616
16.3.2 Examples Using Arrays 547 19.5 Linked Lists 618
16.3.3 Arrays as Parameters 550 19.5.1 Support Functions 620
16.3.4 Strings in C 552 19.5.2 Adding a Node to a Linked List 622
16.3.5 The Relationship Between Arrays and 19.5.3 Deleting Node from a Linked List 625
Pointers in C 554 19.5.4 Arrays vs. Linked Lists 626
xii Contents

19.6 Summary 628 C The Microarchitecture of


Exercises 629 the LC-3 699
C.1 Overview 699
C.2 The State Machine 701
20 Introduction to C++ 633 C.3 The Data Path 703
20.1 Essential C++ 633 C.4 The Control Structure 706
20.2 Going from C to C++ 634 C.5 The TRAP Instruction 710
20.2.1 Compiling C++ Code 634 C.6 Memory-Mapped I/O 711
20.2.2 Namespaces 636 C.7 Interrupt and Exception Control 712
20.2.3 Input and Output 636 C.7.1 Initiating an Interrupt 714
20.2.4 Pass by Reference 637 C.7.2 Returning from an Interrupt or Trap
20.2.5 Function Overloading 638 Service Routine, RTI 717
20.2.6 Dynamic Allocation 639 C.7.3 Initiating an Exception 717
20.2.7 Compilation to Machine C.8 Control Store 719
Version 639
20.3 Classes 639
20.3.1 Methods 640
20.3.2 Access Specifiers 642
20.3.3 Constructors 644 D The C Programming
20.3.4 Advanced Topics 645 Language 721
20.4 Containers and Templates 647 D.1 Overview 721
20.4.1 Vectors 647 D.2 C Conventions 721
20.4.2 Templates 649 D.2.1 Source Files 721
20.5 Summary 649 D.2.2 Header Files 721
Exercises 650 D.2.3 Comments 722
D.2.4 Literals 722
D.2.5 Formatting 724
A The LC-3 ISA 653 D.2.6 Keywords 724
A.1 Overview 653 D.3 Types 725
A.2 The Instruction Set 655 D.3.1 Basic Data Types 725
A.3 Interrupt and Exception Processing 675 D.3.2 Type Qualifiers 726
A.3.1 Interrupts 676 D.3.3 Storage Class 728
A.3.2 Exceptions 676 D.3.4 Derived Types 728
D.3.5 typedef 731
D.4 Declarations 731
B From LC-3 to x86 679 D.4.1 Variable Declarations 731
B.1 LC-3 Features and Corresponding x86 D.4.2 Function Declarations 732
Features 680 D.5 Operators 733
B.1.1 Instruction Set 680 D.5.1 Assignment Operators 733
B.1.2 Memory 685 D.5.2 Arithmetic Operators 734
B.1.3 Internal State 687 D.5.3 Bit-Wise Operators 734
B.2 The Format and Specification of D.5.4 Logical Operators 735
x86 Instructions 690 D.5.5 Relational Operators 735
B.2.1 Prefix 691 D.5.6 Increment/Decrement Operators 736
B.2.2 Opcode 691 D.5.7 Conditional Expression Operators 736
B.2.3 ModR/M Byte 692 D.5.8 Pointer, Array, and Structure
B.2.4 SIB Byte 693 Operators 737
B.2.5 Displacement 693 D.5.9 sizeof 738
B.2.6 Immediate 693 D.5.10 Order of Evaluation 738
B.3 An Example 695 D.5.11 Type Conversions 739
Contents xiii

D.6 Expressions and Statements 740 D.9 Some Standard Library Functions 747
D.6.1 Expressions 740 D.9.1 I/O Functions 747
D.6.2 Statements 740 D.9.2 String Functions 749
D.7 Control 741 D.9.3 Math Functions 750
D.7.1 If 741 D.9.4 Utility Functions 750
D.7.2 If-else 741
D.7.3 Switch 742
D.7.4 While 743 E Useful Tables 753
D.7.5 For 743 E.1 Commonly Used Numerical Prefixes 753
D.7.6 Do-while 744 E.2 Standard ASCII codes 754
D.7.7 Break 744 E.3 Powers of 2 755
D.7.8 continue 745
D.7.9 return 745
D.8 The C Preprocessor 746
D.8.1 Macro Substitution 746 F Solutions to Selected
D.8.2 File Inclusion 747 Exercises 757
Preface

Finally, the third edition! We must first thank all those who have been pushing
us to produce a third edition. Since the publication of the second edition was so
long ago, clearly the material must be out of date. Wrong! Fundamentals do not
change very often, and our intent continues to be to provide a book that explains
the fundamentals clearly in the belief that if the fundamentals are mastered, there
is no limit to how high one can soar if one’s talent and focus are equal to the task.
We must also apologize that it took so long to produce this revision. Please
know that the delay in no way reflects any lack of enthusiasm on our part. We are
both as passionate about the foundation of computing today as we were 25 years
ago when we overhauled the first course in computing that eventually became
the first edition of this book. Indeed, we have both continued to teach the course
regularly. And, as expected, each time we teach, we develop new insights as to
what to teach, new examples to explain things, and new ways to look at things.
The result of all this, hopefully, is that we have captured this in the third edition.
It is a pleasure to finally be writing this preface. We have received an enor-
mous number of comments from students who have studied the material in the
book and from instructors who have taught from it. 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) and watching stu-
dents learn from it (in the case of instructors). The excitement displayed in their
correspondence continues to motivate us.

Why the Book Happened


This textbook evolved from EECS 100, the first computing course for computer
science, computer engineering, and electrical engineering majors at the Univer-
sity of Michigan, Ann Arbor, that Kevin Compton and the first author introduced
for the first time in the fall term, 1995.
EECS 100 happened at Michigan because Computer Science and Engi-
neering faculty had been dissatisfied for many years with the lack of student
comprehension of some very basic concepts. For example, students had a lot
of trouble with pointer variables. Recursion seemed to be “magic,” beyond
understanding.
We decided in 1993 that the conventional wisdom of starting with a high-
level programming language, which was the way we (and most universities) were
xvi Preface

doing it, had its shortcomings. We decided that the reason students were not get-
ting it was that they were forced to memorize technical details when they did not
understand the basic underpinnings.
Our result was the bottom-up approach taken in this book, where we contin-
ually build on what the student already knows, only memorizing when absolutely
necessary. We did not endorse then and we do not endorse now the popular
information hiding approach when it comes to learning. Information hiding is a
useful productivity enhancement technique after one understands what is going on.
But until one gets to that point, we insist that information hiding gets in the way of
understanding. Thus, we continually build on what has gone before so that nothing
is magic and everything can be tied to the foundation that has already been laid.
We should point out that we do not disagree with the notion of top-down
design. On the contrary, we believe strongly that top-down design is correct
design. But there is a clear difference between how one approaches a design prob-
lem (after one understands the underlying building blocks) and what it takes to get
to the point where one does understand the building blocks. In short, we believe
in top-down design, but bottom-up learning for understanding.

Major Changes in the Third Edition


The LC-3
A hallmark of our book continues to be the LC-3 ISA, which is small enough to
be described in a few pages and hopefully mastered in a very short time, yet rich
enough to convey the essence of what an ISA provides. It is the LC “3” because
it took us three tries to get it right. Four tries, actually, but the two changes in the
LC-3 ISA since the second edition (i.e., changes to the LEA instruction and to the
TRAP instruction) are so minor that we decided not to call the slightly modified
ISA the LC-4.
The LEA instruction no longer sets condition codes. It used to set condition
codes on the mistaken belief that since LEA stands for Load Effective Address,
it should set condition codes like LD, LDI, and LDR do. We recognize now that
this reason was silly. LD, LDI, and LDR load a register from memory, and so
the condition codes provide useful information – whether the value loaded is
negative, zero, or positive. LEA loads an address into a register, and for that, the
condition codes do not really provide any value. Legacy code written before this
change should still run correctly.
The TRAP instruction no longer stores the linkage back to the calling pro-
gram in R7. Instead, the PC and PSR are pushed onto the system stack and popped
by the RTI instruction (renamed Return from Trap or Interrupt) as the last instruc-
tion in a trap routine. Trap routines now execute in privileged memory (x0000 to
x2FFF). This change allows trap routines to be re-entrant. It does not affect old
code provided the starting address of the trap service routines, obtained from the
Trap Vector Table, is in privileged memory and the terminating instruction of
each trap service routine is changed from RET to RTI.
As before, Appendix A specifies the LC-3 completely.
Preface xvii

The Addition of C++


We’ve had an ongoing debate about how to extend our approach and textbook
to C++. One of the concerns about C++ is that many of its language features
are too far abstracted from the underlying layers to make for an easy fit to our
approach. Another concern is that C++ is such a vast language that any adequate
coverage would require an additional thousand pages. We also didn’t want to drop
C completely, as it serves as a de facto development language for systems and
hardware-oriented projects.
We adopted an approach where we cover the common core of C and C++
from Chapters 11 through 19. This common core is similar to what was covered
in the second edition, with some minor updates. Chapter 20 serves as a transition,
which we aspired to make very smooth, to the core concepts of C++. With this
approach, we get to explore the evolution between C and C++, which serves as
a key learning opportunity on what changes were essential to boost programmer
productivity.
In particular, we focus on classes in C++ as an evolution from structures in
C. We discuss classes as a compiler construct, how method calls are made, and
the notion of constructors. We touch upon inheritance, too, but leave the details
for subsequent treatment in follow-on courses.
An important element of C++ is the introduction of container classes in the
Standard Template Library, which is a heavily utilized part of the C++ language.
This provides an opportunity to dive deep into the vector class, which serves as
a continuation of a running example in the second half around the support for
variable-sized arrays in high-level languages, or in particular, C’s lack of support
for them.

Other Important Updates


Although no chapter in the book has remained untouched, some chapters have
been changed more than others. In Chapter 2, we expanded the coverage of the
floating point data type and the conversion of fractions between decimal and
binary numbers in response to several instructors who wanted them. We moved
DeMorgan’s Laws from Chapter 3 to Chapter 2 because the concept is really about
AND and OR functions and not about digital logic implementation. In Chap-
ter 3, we completely overhauled the description of state, latches, flip-flops, finite
state machines, and our example of a danger sign. We felt the explanations in the
second edition were not as clear as they needed to be, and the concepts are too
important to not get right. We revised Chapter 4 to better introduce the LC-3,
including a different set of instructions, leading to our first complete example of
a computer program.
Our organization of Chapters 8, 9, and 10 was completely overhauled in order
to present essentially the same material in a more understandable way. Although
most of our treatment of data structures waits until we have introduced C in the
second half of the book, we felt it was important to introduce stacks, queues,
and character strings as soon as the students have moved out of programming in
machine language so they can write programs dealing with these data structures
xviii Preface

and see how these structures are actually organized in memory. We moved our dis-
cussion of subroutines up to Chapter 8 because of their importance in constructing
richer programs.
We also introduced recursion in Chapter 8, although its main treatment is still
left for the second half of the book. Both the expressive power of recursion and
its misuse are so common in undergraduate curricula that we felt dealing with
it twice, first while they are engrossed in the bowels of assembly language and
again after moving up to the richness of C, was worthwhile.
Chapter 9 now covers all aspects of I/O in one place, including polling and
interrupt-driven I/O. Although the concept of privilege is present in the second
edition, we have put greater emphasis on it in the third edition. Our coverage
of system calls (the trap routines invoked by the TRAP instruction) appears in
Chapter 9. All of the above reduce Chapter 10 to simply a comprehensive example
that pulls together a lot of the first half of the book: the simulation of a calculator.
Doing so requires 12 subroutines that are laid out in complete detail. Two con-
cepts that are needed to make this happen are stack arithmetic and ASCII/binary
conversion, so they are included in Chapter 10.
We reworked all the examples in Chapters 11 through 19 to use the latest
ANSI Standard C or C18. We also added more coding examples to further empha-
size points and to provide clarity on complex topics such as pointers, arrays,
recursion, and pointers to pointers in C. In Chapter 16, we added additional
sections on variable-sized arrays in C, and on multidimensional arrays.

Chapter Organization
The book breaks down into two major segments, (a) the underlying structure
of a computer, as manifested in the LC-3; and (b) programming in a high-level
language, in our case C and C++.

The LC-3
We start with the underpinnings that are needed to understand the workings of a
real computer. Chapter 2 introduces the bit and arithmetic and logical operations
on bits. Then we begin to build the structure needed to understand the LC-3.
Chapter 3 takes the student from an MOS transistor, step by step, to a “real”
memory and a finite state machine.
Our real memory consists of four words of three bits each, rather than
16 gigabytes, which is common in most laptops today. Its description fits on a
single page (Figure 3.20), making it easy for a student to grasp. By the time stu-
dents get there, they have been exposed to all the elements needed to construct the
memory. The finite state machine is needed to understand how a computer pro-
cesses instructions, starting in Chapter 4. Chapter 4 introduces the von Neumann
execution model and enough LC-3 instructions to allow an LC-3 program to be
written. Chapter 5 introduces most of the rest of the LC-3 ISA.
Preface xix

The LC-3 is a 16-bit architecture that includes physical I/O via keyboard
and monitor, TRAPs to the operating system for handling service calls, con-
ditional branches on (N, Z, and P) condition codes, a subroutine call/return
mechanism, a minimal set of operate instructions (ADD, AND, and NOT), and
various addressing modes for loads and stores (direct, indirect, Base+offset).
Chapter 6 is devoted to programming methodology (stepwise refinement)
and debugging, and Chapter 7 is an introduction to assembly language program-
ming. We have developed a simulator and an assembler for the LC-3 that runs on
Windows, Linux, and Mac0S platforms. It can be downloaded from the web at
no charge.
Students use the simulator to test and debug programs written in LC-3
machine language and in LC-3 assembly language. The simulator allows online
debugging (deposit, examine, single-step, set breakpoint, and so on). The sim-
ulator can be used for simple LC-3 machine language and assembly language
programming assignments, which are essential for students to master the concepts
presented throughout the first ten chapters.
Assembly language is taught, but not to train expert assembly language pro-
grammers. Indeed, if the purpose was to train assembly language programmers,
the material would be presented in an upper-level course, not in an introductory
course for freshmen. Rather, the material is presented in Chapter 7 because it
is consistent with the paradigm of the book. In our bottom-up approach, by the
time the student reaches Chapter 7, he/she can handle the process of transform-
ing assembly language programs to sequences of 0s and 1s. We go through the
process of assembly step by step for a very simple LC-3 Assembler. By hand
assembling, the student (at a very small additional cost in time) reinforces the
important fundamental concept of translation.
It is also the case that assembly language provides a user-friendly notation
to describe machine instructions, something that is particularly useful for writing
programs in Chapters 8, 9, and 10, and for providing many of the explanations in
the second half of the book. Starting in Chapter 11, when we teach the semantics
of C statements, it is far easier for the reader to deal with ADD R1, R2, R3 than
to have to struggle with 0001001010000011.
Chapter 8 introduces three important data structures: the stack, the queue,
and the character string, and shows how they are stored in memory. The sub-
routine call/return mechanism of the LC-3 is presented because of its usefulness
both in manipulating these data structures and in writing programs. We also intro-
duce recursion, a powerful construct that we revisit much more thoroughly in the
second half of the book (in Chapter 17), after the student has acquired a much
stronger capability in high-level language programming. We introduce recursion
here to show by means of a few examples the execution-time tradeoffs incurred
with recursion as a first step in understanding when its use makes sense and when
it doesn’t.
Chapter 9 deals with input/output and some basic interaction between the
processor and the operating system. We introduce the notions of priority and
privilege, which are central to a systems environment. Our treatment of I/O is
all physical, using keyboard data and status registers for input and display data
and status registers for output. We describe both interrupt-driven I/O and I/O
xx Preface

under program control. Both are supported by our LC-3 simulator so the student
can write interrupt drivers. Finally, we show the actual LC-3 code of the trap ser-
vice routines that the student has invoked with the TRAP instruction starting in
Chapter 4. To handle interrupt-driven I/O and trap service routines, we complete
the description of the LC-3 ISA with details of the operation of the Return from
Trap or Interrupt (RTI) and TRAP instructions.
The first half of the book concludes with Chapter 10, a comprehensive exam-
ple of a simple calculator that pulls together a lot of what the students have learned
in Chapters 1 through 9.

Programming in C and C++


By the time the student gets to the second part of the textbook, he/she has an
understanding of the layers below. In our coverage of programming in C and
C++, we leverage this foundation by showing the resulting LC-3 code generated
by a compiler with each new concept in C/C++.
We start with the C language because it provides the common, essential
core with C++. The C programming language fits very nicely with our bottom-
up approach. Its low-level nature allows students to see clearly the connection
between software and the underlying hardware. In this book, we focus on basic
concepts such as control structures, functions, and arrays. Once basic program-
ming concepts are mastered, it is a short step for students to learn more advanced
concepts such as objects and abstraction in C++.
Each time a new high-level construct is introduced, the student is shown
the LC-3 code that a compiler would produce. We cover the basic constructs of
C (variables, operators, control, and functions), pointers, arrays, recursion, I/O,
complex data structures, and dynamic allocation. With C++, we cover some basic
improvements over C, classes, and containers.
Chapter 11 is a gentle introduction to high-level programming languages. At
this point, students have dealt heavily with assembly language and can understand
the motivation behind what high-level programming languages provide. Chapter
11 also contains a simple C program, which we use to kick-start the process of
learning C.
Chapter 12 deals with values, variables, constants, and operators. Chapter 13
introduces C control structures. We provide many complete program examples
to give students a sample of how each of these concepts is used in practice. LC-3
code is used to demonstrate how each C construct affects the machine at the lower
levels.
Chapter 14 introduces functions in C. Students are not merely exposed to the
syntax of functions. Rather they learn how functions are actually executed, with
argument-passing using a run-time stack. A number of examples are provided.
In Chapter 15, students are exposed to techniques for testing their code, along
with debugging high-level source code. The ideas of white-box and black-box
testing are discussed.
Chapter 16 teaches pointers and arrays, relying heavily on the student’s
understanding of how memory is organized. We discuss C’s notions of fixed size
and variable-length arrays, along with multidimensional array allocation.
Preface xxi

Chapter 17 teaches recursion, using the student’s newly gained knowledge of


functions, stack frames, and the run-time stack. Chapter 18 introduces the details
of I/O functions in C, in particular, streams, variable length argument lists, and
how C I/O is affected by the various format specifications. This chapter relies on
the student’s earlier exposure to physical I/O in Chapter 8. Chapter 19 discusses
structures in C, dynamic memory allocation, and linked lists.
Chapter 20 provides a jump-start on C++ programming by discussing its
roots in C and introducing the idea of classes as a natural evolution from struc-
tures. We also cover the idea of containers in the standard template library, to
enable students to quickly jump into productive programming with C++.
Along the way, we have tried to emphasize good programming style and cod-
ing methodology by means of examples. Novice programmers probably learn at
least as much from the programming examples they read as from the rules they
are forced to study. Insights that accompany these examples are highlighted by
means of lightbulb icons that are included in the margins.
We have found that the concept of pointer variables (Chapter 16) is not at all
a problem. By the time students encounter it, they have a good understanding of
what memory is all about, since they have analyzed the logic design of a small
memory (Chapter 3). They know the difference, for example, between a memory
location’s address and the data stored there.
Recursion ceases to be magic since, by the time a student gets to that point
(Chapter 17), he/she has already encountered all the underpinnings. Students
understand how stacks work at the machine level (Chapter 8), and they understand
the call/return mechanism from their LC-3 machine language programming expe-
rience, and the need for linkages between a called program and the return to the
caller (Chapter 8). From this foundation, it is not a large step to explain functions
by introducing run-time stack frames (Chapter 14), with a lot of the mystery about
argument passing, dynamic declarations, and so on, going away. Since a function
can call a function, it is one additional small step (certainly no magic involved)
for a function to call itself.

The Simulator/Debugger
The importance of the Simulator/Debugger for testing the programs a student
writes cannot be overemphasized. We believe strongly that there is no substi-
tute for hands-on practice testing one’s knowledge. It is incredibly fulfilling
to a student’s education to write a program that does not work, testing it to
find out why it does not work, fixing the bugs himself/herself, and then see-
ing the program run correctly. To that end, the Simulator/Debugger has been
completely rewritten. It runs on Windows, Linux, and MacOS while present-
ing the same user interface (GUI) regardless of which platform the student is
using. We have improved our incorporation of interrupt-driven I/O into the Sim-
ulator’s functionality so students can easily write interrupt drivers and invoke
them by interrupting a lower priority executing program. ...in their first course in
computing!
xxii Preface

Alternate Uses of the Book


We wrote the book as a textbook for a freshman introduction to computing. We
strongly believe that our motivated bottom-up approach is the best way for stu-
dents to learn the fundamentals of computing. We have seen lots of evidence
showing that in general, students who understand the fundamentals of how the
computer works are better able to grasp the stuff that they encounter later, includ-
ing 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.
Having said that, we recognize that others see the curriculum differently.
Thus, we hasten to add that the book can certainly be used effectively in other
ways. In fact, each of the following has been tried, and all have been used
successfully:
Two Quarters, Freshman Course
An excellent use of the book. No prerequisites, the entire book can be covered
easily in two quarters, the first quarter for Chapters 1–10, the second quarter for
Chapters 11–20. The pace is brisk, but the entire book can be covered easily in
two academic quarters.
One-Semester, Second Course
Several schools have successfully used the book in their second course,
after the students have been exposed to programming with an object-oriented
programming language in a milder first course. The rationale is that after expo-
sure 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. The first two-thirds of the semester is spent
on Chapters 1–10, and the last third on Chapters 11–20, teaching C programming,
but also showing how some of the magic from the students’ first course can be
implemented. Coverage of functions, activation records, recursion, pointer vari-
ables, and data structures are examples of topics where getting past the magic is
particularly useful. The second half of the book can move more quickly since the
student has already taken an introductory programming course. This model also
allows students who were introduced to programming with an object-oriented
language to pick up C, which they will almost certainly need in some of their
advanced software courses.
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, often
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 in the book, most
notably cache memory, pipelining, and virtual memory. Instructors using the
book this way are encouraged to provide extra handouts dealing with those top-
ics. We agree that they are very important to the student’s computer architecture
Preface xxiii

education, but we feel they are better suited to a later course in computer
architecture and design. This book is not intended for that purpose.

Why LC-3, and Not ARM or RISCV?


We have been asked why we invented the LC-3 ISA, rather than going with ARM,
which seems to be the ISA of choice for most mobile devices, or RISCV, which
has attracted substantial interest over the last few years.
There are many reasons. First, we knew that the ISA we selected would
be the student’s first ISA, not his/her last ISA. Between the freshman year and
graduation, the student is likely to encounter several ISAs, most of which are in
commercial products: ARM, RISCV, x86, and POWER, to name a few.
But all the commercial ISAs have details that have no place in an introductory
course but still have to be understood for the student to use them effectively. We
could, of course, have subset an existing ISA, but that always ends up in questions
of what to take out and what to leave in with a result that is not as clean as one
would think at first blush. Certainly not as clean as what one can get when starting
from scratch. It also creates an issue whenever the student uses an instruction in
an exam or on an assignment that is not in the subset. Not very clean from a
pedagogical sense.
We wanted an ISA that was clean with no special cases to deal with, with as
few opcodes as necessary so the student could spend almost all his/her time on
the fundamental concepts in the course and very little time on the nuances of the
instruction set. The formats of all instructions in the LC-3 fit on a single page.
Appendix A provides all the details (i.e., the complete data sheet) of the entire
LC-3 ISA in 25 pages.
We also wanted an instruction set that in addition to containing only a few
instructions was very rich in the breadth of what it embraced. So, we came up
with the LC-3, an instruction set with only 15 four-bit opcodes, a small enough
number that students can absorb the ISA without even trying. For arithmetic, we
have only ADD instead of ADD, SUB, MUL, and DIV. For logical operations,
we have AND and NOT, foregoing OR, XOR, etc. We have no shift or rotate
instructions. In all these cases, the missing opcodes can be implemented with
procedures using the few opcodes that the LC-3 provides. We have loads and
stores with three different addressing modes, each addressing mode useful for a
different purpose. We have conditional branches, subroutine calls, return from
trap or interrupt, and system calls (the TRAP instruction).
In fact, this sparse set of opcodes is a feature! It drives home the need for
creating more complex functionality out of simple operations, and the need for
abstraction, both of which are core concepts in the book.
Most importantly, we have found from discussions with hundreds of students
that starting with the LC-3 does not put them at a disadvantage in later courses.
On the contrary: For example, at one campus students were introduced to ARM in
the follow-on course, while at another campus, students were introduced to x86.
xxiv Preface

In both cases, students appreciated starting with the LC-3, and their subsequent
introduction to ARM or x86 was much easier as a result of their first learning the
fundamental concepts with the LC-3.

A Few Observations
Having now taught the course more than 20 times between us, we note the
following:

Understanding, Not Memorizing


Since the course builds from the bottom up, we have found that less memorization
of seemingly arbitrary rules is required than in traditional programming courses.
Students understand that the rules make sense since by the time a topic is taught,
they have an awareness of how that topic is implemented at the levels below
it. This approach is good preparation for later courses in design, where under-
standing of and insights gained from fundamental underpinnings are essential to
making the required design tradeoffs.

The Student Debugs the Student’s Program


We hear complaints from industry all the time about CS graduates not being able
to program. Part of the problem is the helpful teaching assistant, who contributes
far too much of the intellectual content of the student’s program so the student
never has to really master the art. Our approach is to push the student to do the
job without the teaching assistant (TA). Part of this comes from the bottom-up
approach, where memorizing is minimized and the student builds on what he/she
already knows. Part of this is the simulator, which the student uses from the day
he/she writes his/her first program. The student is taught debugging from his/her
first program and is required from the very beginning to use the debugging tools
of the simulator to get his/her programs to work. The combination of the simulator
and the order in which the subject material is taught results in students actually
debugging their own programs instead of taking their programs to the TA for
help ... with the too-frequent result that the TAs end up writing the programs for
the students.

Preparation for the Future: Cutting Through Protective Layers


Professionals who use computers in systems today but remain ignorant of what
is going on underneath are likely to discover the hard way that the effectiveness
of their solutions is impacted adversely by things other than the actual programs
they write. This is true for the sophisticated computer programmer as well as the
sophisticated engineer.
Serious programmers will write more efficient code if they understand what
is going on beyond the statements in their high-level language. Engineers, and not
just computer engineers, are having to interact with their computer systems today
Discovering Diverse Content Through
Random Scribd Documents
1.F.1. Project Gutenberg volunteers and employees expend
considerable effort to identify, do copyright research on,
transcribe and proofread works not protected by U.S. copyright
law in creating the Project Gutenberg™ collection. Despite these
efforts, Project Gutenberg™ electronic works, and the medium
on which they may be stored, may contain “Defects,” such as,
but not limited to, incomplete, inaccurate or corrupt data,
transcription errors, a copyright or other intellectual property
infringement, a defective or damaged disk or other medium, a
computer virus, or computer codes that damage or cannot be
read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in
paragraph 1.F.3, the Project Gutenberg Literary Archive
Foundation, the owner of the Project Gutenberg™ trademark,
and any other party distributing a Project Gutenberg™ electronic
work under this agreement, disclaim all liability to you for
damages, costs and expenses, including legal fees. YOU AGREE
THAT YOU HAVE NO REMEDIES FOR NEGLIGENCE, STRICT
LIABILITY, BREACH OF WARRANTY OR BREACH OF CONTRACT
EXCEPT THOSE PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE
THAT THE FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of
receiving it, you can receive a refund of the money (if any) you
paid for it by sending a written explanation to the person you
received the work from. If you received the work on a physical
medium, you must return the medium with your written
explanation. The person or entity that provided you with the
defective work may elect to provide a replacement copy in lieu
of a refund. If you received the work electronically, the person
or entity providing it to you may choose to give you a second
opportunity to receive the work electronically in lieu of a refund.
If the second copy is also defective, you may demand a refund
in writing without further opportunities to fix the problem.

1.F.4. Except for the limited right of replacement or refund set


forth in paragraph 1.F.3, this work is provided to you ‘AS-IS’,
WITH NO OTHER WARRANTIES OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of
damages. If any disclaimer or limitation set forth in this
agreement violates the law of the state applicable to this
agreement, the agreement shall be interpreted to make the
maximum disclaimer or limitation permitted by the applicable
state law. The invalidity or unenforceability of any provision of
this agreement shall not void the remaining provisions.

1.F.6. INDEMNITY - You agree to indemnify and hold the


Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and
distribution of Project Gutenberg™ electronic works, harmless
from all liability, costs and expenses, including legal fees, that
arise directly or indirectly from any of the following which you
do or cause to occur: (a) distribution of this or any Project
Gutenberg™ work, (b) alteration, modification, or additions or
deletions to any Project Gutenberg™ work, and (c) any Defect
you cause.
Section 2. Information about the Mission
of Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new
computers. It exists because of the efforts of hundreds of
volunteers and donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project
Gutenberg™’s goals and ensuring that the Project Gutenberg™
collection will remain freely available for generations to come. In
2001, the Project Gutenberg Literary Archive Foundation was
created to provide a secure and permanent future for Project
Gutenberg™ and future generations. To learn more about the
Project Gutenberg Literary Archive Foundation and how your
efforts and donations can help, see Sections 3 and 4 and the
Foundation information page at www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-
profit 501(c)(3) educational corporation organized under the
laws of the state of Mississippi and granted tax exempt status
by the Internal Revenue Service. The Foundation’s EIN or
federal tax identification number is 64-6221541. Contributions
to the Project Gutenberg Literary Archive Foundation are tax
deductible to the full extent permitted by U.S. federal laws and
your state’s laws.

The Foundation’s business office is located at 809 North 1500


West, Salt Lake City, UT 84116, (801) 596-1887. Email contact
links and up to date contact information can be found at the
Foundation’s website and official page at
www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission
of increasing the number of public domain and licensed works
that can be freely distributed in machine-readable form
accessible by the widest array of equipment including outdated
equipment. Many small donations ($1 to $5,000) are particularly
important to maintaining tax exempt status with the IRS.

The Foundation is committed to complying with the laws


regulating charities and charitable donations in all 50 states of
the United States. Compliance requirements are not uniform
and it takes a considerable effort, much paperwork and many
fees to meet and keep up with these requirements. We do not
solicit donations in locations where we have not received written
confirmation of compliance. To SEND DONATIONS or determine
the status of compliance for any particular state visit
www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states


where we have not met the solicitation requirements, we know
of no prohibition against accepting unsolicited donations from
donors in such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot


make any statements concerning tax treatment of donations
received from outside the United States. U.S. laws alone swamp
our small staff.
Please check the Project Gutenberg web pages for current
donation methods and addresses. Donations are accepted in a
number of other ways including checks, online payments and
credit card donations. To donate, please visit:
www.gutenberg.org/donate.

Section 5. General Information About


Project Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could
be freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose
network of volunteer support.

Project Gutenberg™ eBooks are often created from several


printed editions, all of which are confirmed as not protected by
copyright in the U.S. unless a copyright notice is included. Thus,
we do not necessarily keep eBooks in compliance with any
particular paper edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg
Literary Archive Foundation, how to help produce our new
eBooks, and how to subscribe to our email newsletter to hear
about new eBooks.
Welcome to Our Bookstore - The Ultimate Destination for Book Lovers
Are you passionate about testbank and eager to explore new worlds of
knowledge? At our website, we offer a vast collection of books that
cater to every interest and age group. From classic literature to
specialized publications, self-help books, and children’s stories, we
have it all! Each book is a gateway to new adventures, helping you
expand your knowledge and nourish your soul
Experience Convenient and Enjoyable Book Shopping Our website is more
than just an online bookstore—it’s a bridge connecting readers to the
timeless values of culture and wisdom. With a sleek and user-friendly
interface and a smart search system, you can find your favorite books
quickly and easily. Enjoy special promotions, fast home delivery, and
a seamless shopping experience that saves you time and enhances your
love for reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!

ebooksecure.com

You might also like