SlideShare a Scribd company logo
Introduction to Computing Systems From bits and
gates to C and beyond 2nd International Edition Yale
Patt - Downloadable PDF 2025
https://ebookfinal.com/download/introduction-to-computing-systems-from-
bits-and-gates-to-c-and-beyond-2nd-international-edition-yale-patt/
Visit ebookfinal.com today to download the complete set of
ebooks or textbooks
Here are some recommended products that we believe you will be
interested in. You can click the link to download.
From Kosovo to Kabul and Beyond Human Rights and
International Intervention David Chandler
https://ebookfinal.com/download/from-kosovo-to-kabul-and-beyond-human-
rights-and-international-intervention-david-chandler/
Introduction to Grid Computing 1st Edition Frederic
Magoules
https://ebookfinal.com/download/introduction-to-grid-computing-1st-
edition-frederic-magoules/
Database Systems Introduction to Databases and Data
Warehouses 2nd Edition Nenad Jukic■
https://ebookfinal.com/download/database-systems-introduction-to-
databases-and-data-warehouses-2nd-edition-nenad-jukic/
Introduction to Optical Microscopy 2nd Edition Jerome C.
Mertz
https://ebookfinal.com/download/introduction-to-optical-
microscopy-2nd-edition-jerome-c-mertz/
Practicing Harm Reduction Psychotherapy An Alternative
Approach to Addictions 2nd Edition Patt Denning
https://ebookfinal.com/download/practicing-harm-reduction-
psychotherapy-an-alternative-approach-to-addictions-2nd-edition-patt-
denning/
Introduction to Building Procurement Systems 2nd Edition
Dr Jack Masterman
https://ebookfinal.com/download/introduction-to-building-procurement-
systems-2nd-edition-dr-jack-masterman/
Introduction to High Performance Computing for Scientists
and Engineers 1st Edition Georg Hager
https://ebookfinal.com/download/introduction-to-high-performance-
computing-for-scientists-and-engineers-1st-edition-georg-hager/
Stimuli Responsive Drug Delivery Systems From Introduction
to Application 1st Edition Bajpai
https://ebookfinal.com/download/stimuli-responsive-drug-delivery-
systems-from-introduction-to-application-1st-edition-bajpai/
Structure and Function From clause to discourse and beyond
Christopher Butler
https://ebookfinal.com/download/structure-and-function-from-clause-to-
discourse-and-beyond-christopher-butler/
Introduction to Computing Systems From bits and gates to C and beyond 2nd International Edition Yale Patt
Introduction to Computing Systems From bits and gates
to C and beyond 2nd International Edition Yale Patt
Digital Instant Download
Author(s): Yale Patt, Sanjay Patel
ISBN(s): 9780071245012, 0071245014
Edition: 2nd International
File Details: PDF, 13.10 MB
Year: 2005
Language: english
introduction to
computing systems
The McGraw-Hill Companies
Mc
Graw
Hill
INTRODUCTION TO COMPUTING SYSTEMS: FROM BITS AND GATES TO C AND BEYOND
SECOND EDITION
International Edition 2005
Exclusive rights by McGraw-Hill Education (Asia), for manufacture and export. This book cannot be
re-exported from the country to which it is sold by McGraw-Hill. The International Edition is not
available in North America.
Published by McGraw-Hill, a business unit of The McGraw-Hill Companies, Inc., 1221 Avenue of the
Americas, New York, NY 10020. Copyright © 2004, 2001 by The McGraw-Hill Companies, Inc. All
rights reserved. 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 The McGraw-
Hill Companies, Inc., 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.
10 09 08 07 06 05 04 03 02 01
20 09 08 07 06 05 04
CTF SEP
Cover images: ©Photodisc, AA048376 Green Abstract, AA003317 Circuit Board Detail
Library of Congress Control Number: 2003051002
When ordering this title, use ISBN 007-124501-4
Printed in Singapore
> > second edition
introduction to
computing systems
from bits and gates to C and beyond
Yale N. Patt
The University of Texas at Austin
Sanjay J. Patel
University of Illinois at Urbana-Champaign
Mc
Graw
Hill
Higher Education
Boston Burr Ridge, IL Dubuque, IA Madison, Wl New York San Francisco St. Louis
Bangkok Bogota Caracas Kuala Lumpur Lisbon London Madrid Mexico City
Milan Montreal New Delhi Santiago Seoul Singapore Sydney Taipei Toronto
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 Mira and her grandparents,
Sharda Patel and Jeram Patel.
contents
Preface xi
Preface to the First Edition
1 Welcome Aboard 1
XVII
2.4.1 Binary to Decimal Conversion 27
2.4.2 Decimal to Binary Conversion 28
1.1
1.2
1.3
1.4
1.5
1.6
1.7
What We Will Try to Do 1
How We Will Get There 2
Two Recurring Themes 3
1.3.1 The Notion of Abstraction 3
1.3.2 Hardware versus Software 5
A Computer System 7
Two Very Important Ideas 9
Computers as Universal Computational
Devices 9
How Do We Get the Electrons to Do the
Work?
1.7.1
1.7.2
1.7.3
1.7.4
1.7.5
1.7.6
1.7.7
1.7.8
Exercises 17
12
The Statement of the Problem 13
The Algorithm 13
The Program 14
The ISA 14
The Microarchitecture 15
The Logic Circuit 16
The Devices 16
Putting It Together 16
2 Bits, Data Types, and
Operations 21
2.1
2.2
2.3
2.4
Bits and Data Types 21
2.1.1 The Bit as the Unit of
Information 21
2.1.2 Data Types 22
Integer Data Types 23
2.2.1 Unsigned Integers 23
2.2.2 Signed Integers 23
2's Complement Integers 25
Binary-Decimal ..Conversion 27
2.5 Operations on Bits—Part I: Arithmetic
2.5.1 Addition and Subtraction 29
2.5.2 Sign-Extension 30
2.5.3 Overflow 31
2.6 Operations on Bits—Part I I : Logical
Operations 33
2.6.1 v The AND Function 33
2.6.2 The OR Function 34
2.6.3 The NOT Function 35
2.6.4 The Exclusive-OR Function 35
2.7 Other Representations 36
2.7.1 The Bit Vector 36
2.7.2 Floating Point Data Type 37
2.7.3 ASCII Codes 40
2.7.4 Hexadecimal Notation 41
Exercises 43
3 Digital Logic Structures 51
3.1 The Transistor 5 1
3.2 Logic Gates 53
3.2.1 The NOT Gate (Inverter) 53
3.2.2 OR and NOR Gates 54
3.2.3 AND and NAND Gates 56
3.2.4 DeMorgan's Law 58
3.2.5 Larger Gates 58
3.3 Combinational Logic Circuits 59
3.3.1 Decoder 59
3.3.2 Mux 60
3.3.3 Full Adder 61
3.3.4 The Programmable Logic Array
(PLA) 63
3.3.5 Logical Completeness 64
Basic Storage Elements 64
3.4.1 The R-S Latch 64
3.4.2 The Gated D Latch 66
3.4.3 A Register 66
29
3.4
vi Contents
3.5 The Concept of Memory 67
3.5.1 Address Space 68
3.5.2 Addressability 68
3.5.3 A 22
-by-3-Bit Memory 68
3.6 Sequential Logic Circuits 70
3.6.1 A Simple Example: The Combination
Lock 71
3.6.2 The Concept of State 72
3.6.3 Finite State Machines 74
3.6.4 An Example: The Complete
Implementation of a
Finite State Machine 77
3.7 The Data Path of the LC-3 80
Exercises 82
5.4 Control Instructions 130
5.4.1 Conditional Branches 131
5.4.2 An Example 132
5.4.3 Two Methods for Loop Control 135
5.4.4 Example: Adding a Column of
Numbers Using a Sentinel 135
5.4.5 The JMP Instruction 136
5.4.6 The TRAP Instruction 137
5.5 Another Example: Counting Occurrences of
a Character 138
5.6 The Data Path Revisited 141
5.6.1 Basic Components of the Data
Path 141
5.6.2 The Instruction Cycle 144
Exercises 145
4 The von Neumann Model 97
4.1 Basic Components 97
4.1.1 Memory 98
4.1.2 Processing Unit 99
4.1.3 Input and Output 100
4.1.4 Control Unit 100
4.2 The LC-3: An Example von Neumann
Machine 101
4.3 Instruction Processing 103
4.3.1 The Instruction 103
4.3.2 The Instruction Cycle 104
4.4 Changing the Sequence of Execution 107
4.4.1 Control of the Instruction
Cycle 108
4.5 Stopping the Computer 110
Exercises 111
6 Programming 155
6.1 Problem Solving 155
6.1.1 Systematic Decomposition 155
6.1.2 The Three Constructs: Sequential;
Conditional, Iterative 156
6.1.3 LC-3 Control Instructions to
Implement the Three
Constructs 157
6.1.4 The Character Count Example from
Chapter 5, Revisited 158
6.2 Debugging 162
6.2.1 Debugging Operations 163
6.2.2 Examples: Use of the Interactive
Debugger 164
Exercises 172
5 The LC-3 115
5.1 The ISA: Overview 115
5.1.1 Memory Organization 116
5.1.2 Registers 116
5.1.3 The Instruction Set 117
5.1.4 Opcodes 117
5.1.5 Data Types 118
5.1.6 Addressing Modes 118
5.1.7 Condition Codes 120
5.2 Operate Instructions 120
5.3 Data Movement Instructions 123
5.3.1 PC-Relative Mode 124
5.3.2 Indirect Mode 125
5.3.3 Base+offset Mode 127
5.3.4 Immediate Mode 128
5.3.5 An Example 129
7 Assembly Language 177
7.1 Assembly Language Programming —
Moving Up a Level 177
7.2 An Assembly Language Program 178
7.2.1 Instructions 179
7.2.2 Pseudo-ops (Assembler
Directives) 182
7.2.3 Example: The Character Count
Example of Section 5.5,
Revisited 183
7.3 The Assembly Process 185
7.3.1 Introduction 185
7.3.2 A Two-Pass Process 185
7.3.3 The First Pass: Creating the Symbol
Table 186
7.3.4 The Second Pass: Generating the
Machine Language Program 187
Contents vii
7.4 Beyond the Assembly of a Single Assembly
Language Program 188
7.4.1 The Executable Image 189
7.4.2 More than One Object File 189
Exercises 190
8 I/O 199
8.1 I/O Basics 199
8.1.1 Device Registers 199
8.1.2 Memory-Mapped I/O versus Special
Input/Output Instructions 200
8.1.3 Asynchronous versus
Synchronous 200
8.1.4 Interrupt-Driven versus Polling 202
8.2 Input from the Keyboard 202
8.2.1 Basic Input Registers (the KBDR and
the KBSR) 202
8.2.2 The Basic Input Service
Routine 202
8.2.3 Implementation of Memory-Mapped
Input 203
8.3 Output to the Monitor 204
8.3.1 Basic Output Registers (the DDR and
the DSR) 204
8.3.2 The Basic Output Service
Routine 205
8.3.3 Implementation of Memory-Mapped
Output 206
8.3.4 Example: Keyboard Echo 207
8.4 A More Sophisticated Input Routine 207
8.5 Interrupt-Driven I/O 209
8.5.1 What Is Interrupt-Driven I/O? 209
8.5.2 Why Have Interrupt-Driven
I/O? 210
8.5.3 Generation of the Interrupt
Signal 211
8.6 Implementation of Memory-Mapped 1/0/
Revisited 214
Exercises 215
9.1.5 TRAP Routines for Handling
I/O 225
9.1.6 TRAP Routine for Halting the
Computer 225
9.1.7 Saving and Restoring
Registers 229
9.2 Subroutines 230
9.2.1 The Call/Return Mechanism 230
9.2.2 The JSR(R) Instruction 232
9.2.3 The TRAP Routine for Character
Input, Revisited 233
9.2.4 PUTS: Writing a Character String to
the Monitor 235
9.2.5 Library Routines 235
Exercises 240
10 And, Finally . . . The Stack 251
10.1 The Stack: Its Basic Structure 251
10.1.1 The S t a c k - A n Abstract Data
Type 251
10.1.2 Two Example Implementations 252
10.1.3 Implementation in Memory 253
10.1.4 The Complete Picture 257
10.2 Interrupt-Driven I/O (Part 2) 258
10.2.1 Initiate and Service the
Interrupt 259
10.2.2 Return from the Interrupt 261
10.2.3 An Example 262
10.3 Arithmetic Using a Stack 264
10.3.1 The Stack as Temporary
Storage 264
10.3.2 An Example 265
10.3.3 OpAdd, Op Mult, and OpNeg 265
10.4 Data Type Conversion 272
10.4.1 Example: The Bogus Program:
2 + 3 = e 272
10.4.2 ASCII to Binary 273
10.4.3 Binary to ASCII 276
10.5 Our Final Example: The Calculator 278
Exercises 283
9 TRAP Routines and
Subroutines 219
9.1 LC-3 TRAP Routines 219
9.1.1 Introduction 219
9.1.2 The TRAP Mechanism 220
9.1.3 The TRAP Instruction 221
9.1.4 The Complete Mechanism 222
11 Introduction to Programming
inC 289
11.1 Our Objective 289
11.2 Bridging the Gap 290
11.3 Translating High-Level Language
Programs 292
viii Contents
11.3.1 Interpretation 292
11.3.2 Compilation 293
11.3.3 Pros and Cons 293
11.4 The C Programming Language 293
11.4.1 The C Compiler 295
11.5 A Simple Example 297
11.5.1 The Function m a i n 297
11.5.2 Formatting, Comments, and
Style 299
11.5.3 The C Preprocessor 300
11.5.4 Input and Output 3 0 1
11.6 Summary 3 0 4
Exercises 3 0 5
12 Variables and Operators 307
1 2 . 1 Introduction 3 0 7
12.2 Variables 3 0 8
12.2.1 Three Basic Data Types: int, char,
d o u b l e 308
12.2.2 Choosing Identifiers 310
12.2.3 Scope: Local versus Global 3 1 1
12.2.4 More Examples 313
12.3 Operators 3 1 4
12.3.1 Expressions and Statements 315
12.3.2 The Assignment Operator 316
12.3.3 Arithmetic Operators 317
12.3.4 Order of Evaluation 318
12.3.5 Bitwise Operators 319
12.3.6 Relational Operators 320
12.3.7 Logical Operators 322
12.3.8 Increment/Decrement
Operators 322
12.3.9 Expressions with Multiple
Operators 324
12.4 Problem Solving Using Operators 3 2 4
12.5 Tying it All Together 3 2 6
12.5.1 Symbol Table 326
12.5.2 Allocating Space for Variables 328
12.5.3 A Comprehensive Example 331
12.6 Additional Topics 332
12.6.1 Variations of the Three Basic
Types 332
12.6.2 Literals, Constants, and Symbolic
Values 334
12.6.3 Storage Class 335
12.6.4 Additional C Operators 336
12.7 Summary 337
Exercises 3 3 8
13 Control Structures 343
1 3 . 1 Introduction 3 4 3
13.2 Conditional Constructs 3 4 4
13.2.1 The if Statement 344
13.2.2 The if-else Statement 347
13.3 Iteration Constructs 3 5 0
13.3.1 The while Statement 350
13.3.2 The for Statement 353
13.3.3 The do-while Statement 358
13.4 Problem Solving Using Control
Structures 3 5 9
13.4.1 Problem 1: Approximating the Value
of 7i 360
13.4.2 Problem 2: Finding Prime Numbers
Less than 100 362
13.4.3 Problem 3: Analyzing an E-mail
Address 366
13.5 Additional C Control Structures 3 6 8
13.5.1 The switch Statement 368
13.5.2 The break and continue
Statements 370
13.5.3 An Example: Simple
Calculator 370
13.6 Summary 372
Exercises 372
14 Functions 379
1 4 . 1 Introduction 3 7 9
14.2 Functions in C 3 8 0
14.2.1 A Function with a Parameter 380
14.2.2 Example: Area of a Ring 384
14.3 Implementing Functions in C 3 8 5
14.3.1 Run-Time Stack 385
14.3.2 Getting It All to Work 388
14.3.3 Tying It All Together 393
14.4 Problem Solving Using Functions 3 9 4
14.4.1 Problem 1: Case Conversion 395
14.4.2 Problem 2: Pythagorean
Triples 397
14.5 Summary 3 9 8
Exercises 3 9 9
15 Testing and Debugging 407
1 5 . 1 Introduction 4 0 7
15.2 Types of Errors 4 0 8
15.2.1 Syntactic Errors 409
Contents ix
15.2.2 Semantic Errors 409
15.2.3 Algorithmic Errors 411
15.3 Testing 412
15.3.1 Black-Box Testing 412
15.3.2 White-Box Testing 413
15.4 Debugging 414
15.4.1 Ad Hoc Techniques 414
15.4.2 Source-Level Debuggers 415
15.5 Programming for Correctness 417
15.5.1 Nailing Down the
Specification 417
15.5.2 Modular Design 418
15.5.3 Defensive Programming 418
15.6 Summary 419
Exercises 4 2 1
16 Pointers and Arrays 427
16.1 Introduction 427
16.2 Pointers 428
16.2.1 Declaring Pointer Variables 429
16.2.2 Pointer Operators 430
16.2.3 Passing a Reference Using
Pointers 432
16.2.4 Null Pointers 433
16.2.5 Demystifying the Syntax 434
16.2.6 An Example Problem Involving
Pointers 434
16.3 Arrays 436
16.3.1 Declaring and Using
Arrays 436
16.3.2 Examples Using Arrays 438
16.3.3 Arrays as Parameters 440
16.3.4 Strings in C 441
16.3.5 The Relationship Between Arrays and
Pointers in C 446
16.3.6 Problem Solving: Insertion
Sort 446
16.3.7 Common Pitfalls with Arrays
in C 449
16.4 Summary 4 5 1
Exercises 4 5 1
17 Recursion 457
17.1 Introduction 457
17.2 What Is Recursion? 458
17.3 Recursion versus Iteration 459
17.4 Towers of Hanoi 460
17.5 Fibonacci Numbers 464
17.6 Binary Search 468
17.7 Integer to A S C I I 4 7 1
17.8 Summary 473
Exercises 473
18 I/O in C 481
18.1 Introduction 4 8 1
18.2 The C Standard Library 4 8 1
18.3 I/O, One Character at a Time 482
18.3.1 I/O Streams 482
18.3.2 p u t c h a r 483
18.3.3 g e t c h a r 483
18.3.4 Buffered I/O 483
18.4 Formatted I/O 485
18.4.1 p r i n t f 485
18.4.2 s c a n f 487
18.4.3 Variable Argument
Lists 489
18.5 I/O from Files 4 9 1
18.6 Summary 493
Exercises 494
19 Data Structures 497
19.1 Introduction 497
19.2 Structures 498
19.2.1 typedef 500
19.2.2 Implementing Structures
in C 501
19.3 Arrays of Structures 502
19.4 Dynamic Memory Allocation 504
19.4.1 Dynamically Sized Arrays 506
19.5 Linked Lists 508
19.5.1 An Example 510
19.6 Summary 516
Exercises 517
A The LC-3 ISA 521
A . l Overview 5 2 1
A.2 Notation 523
A.3 The Instruction Set 523
A.4 Interrupt and Exception Processing 543
A.4.1 Interrupts 543
A.4.2 Exceptions 544
X Contents
B From LC-3 to x86 547
B . l LC-3 Features and Corresponding x86
Features 548
B . l . l Instruction Set 548
B.l.2 Memory 553
B.l.3 Internal State 553
B.2 The Format and Specification of x86
Instructions 557
B.2.1 Prefix 558
B.2.2 Opcode 559
B.2.3 ModR/M Byte 559
B.2.4 SIB Byte 560
B.2.5 Displacement 560
B.2.6 Immediate 560
B.3 An Example 562
C The Microarchitecture of the
LC-3 565
C . l Overview 565
C.2 The State Machine 567
C.3 The Data Path 569
C.4 The Control Structure 569
C.5 Memory-Mapped I/O 575
C.6 Interrupt and Exception Control 576
C.6.1 Initiating an Interrupt 579
C.6.2 Returning from an Interrupt,
RTI 581
C.6.3 The Illegal Opcode Exception 582
C.7 Control Store 583
D The C Programming
Language 585
D . l Overview 585
D.2 C Conventions 585
D.2.1 Source Files 585
D.2.2 Header Files 585
D.2.3 Comments 586
D.2.4 Literals 586
D.2.5 Formatting 588
D.2.6 Keywords 588
D.3 Types 589
D.3.1 Basic Data Types 589
D.3.2 Type Qualifiers 590
D.3.3 Storage Class 591
D.3.4 Derived Types 592
D.3.5 typedef 594
D.4 Declarations 595
D.4.1 Variable Declarations 595
D.4.2 Function Declarations 596
D.5 Operators 596
D.5.1 Assignment Operators 597
Arithmetic Operators 597
Bit-wise Operators 598
Logical Operators 598
Relational Operators 599
I ncrement/Decrement
Operators 599
Conditional Expression 600
Pointer, Array, and Structure
Operators 600
sizeof 601
Order of Evaluation 602
Type Conversions 602
Expressions and Statements 603
D.6.1 Expressions 603
Statements 604
604
I f 604
If-else 605
Switch 605
While 606
For 607
Do-while 607
Break 608
continue 608
return 609
D.8 The C Preprocessor 609
D.8.1 Macro substitution 609
D.8.2 File inclusion 610
D.9 Some Standard Library Functions 610
D.9.1 I/O Functions 611
D.9.2 String Functions 612
D.9.3 Math Functions 613
D.9.4 Utility Functions 613
D.6
D.7
D.5.2
D.5.3
D.5.4
D.5.5
D.5.6
D.5.7
D.5.8
D.5.9
D.5.10
D.5.11
D.6.2
Control
D.7.1
D.7.2
D.7.3
D.7.4
D.7.5
D.7.6
D.7.7
D.7.8
D.7.9
E Useful Tables 615
E . l Commonly Used Numerical Prefixes
E.2 Standard A S C I I codes 616
E.3 Powers of 2 617
F Solutions to Selected
Exercises 619
615
preface
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 how to make itbetter. 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 [lie 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. A majorproblem 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
xii preface
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 program-
ming language. Unlike the first edition, these chapters are more focused on the
essential aspects of the language useful to a beginning programmer. Special-
ized 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 program-
ming. 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. Ashley Wise has written an LC-3 simulator that runs on
UNIX. Both have incorporated interrupt-driven I/O into the simulator's function-
ality. 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.
preface xiii
Alternate Uses of the Booh
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 one-
semester 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.
xhr preface
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 Col-
lege; 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 believ-
ers, 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 as wonderful. 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. Brian Fahs provided solutions to the exercises.
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.
preface xv
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 exten-
sive 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.
f) 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
preface to the first edition
This textbook has evolved from EECS 100, the first computing course for com-
puter science, computer engineering, and electrical engineering majors at the
University of Michigan, that Kevin Compton and the first author introduced for
the first time in the fall term, 1995.
EECS 100 happened because Computer Science and Engineering 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
doing it, had its shortcomings. We decided that the reason students were not
getting it was that they were forced to memorize technical details when they did
not understand the basic underpinnings.
The result is the bottom-up approach taken in this book. We treat (in order)
MOS transistors (very briefly, long enough for students to grasp their global
switch-level behavior), logic gates, latches, logic structures (MUX, Decoder,
Adder, gated latches), finally culminating in an implementation of memory. From
there, we move on to the Von Neumann model of execution, then a simple com-
puter (the LC-2), machine language programming of the LC-2, assembly language
programming of the LC-2, the high level language C, recursion, pointers, arrays,
and finally some elementary data structures.
We do not endorse today's popular information hiding approach when it
comes to learning. Information hiding is a useful productivity enhancement tech-
nique 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 contin-
ually 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
problem (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.
Htiaf Is in the Booh
The book breaks down into two major segments, a) the underlying structure of a
computer, as manifested in the LC-2; and b) programming in ahigh level language,
in our case C.
The LC-2
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-2.
Chapter 3 takes the student from a MOS transistor, step by step, to a real memory.
Our real memory consists of 4 words of 3 bits each, rather than 64 megabytes. The
picture fits on a single page (Figure 3.20), making it easy for a student to grasp.
By the time the students get there, they have been exposed to all the elements that
make memory work. Chapter 4 introduces the Von Neumann execution model,
as a lead-in to Chapter 5, the LC-2.
The LC-2 is a 16-bit architecture that includes physical I/O via keyboard and
monitor; TRAPs to the operating system for handling service calls; conditional
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 address-
ing modes for loads and stores (direct, indirect, Base+offset, and an immediate
mode for loading effective addresses).
Chapter 6 is devoted to programming methodology (stepwise refinement) and
debugging, and Chapter 7 is an introduction to assembly language programming.
We have developed a simulator and an assembler for the LC-2. Actually, we have
developed two simulators, one that runs on Windows platforms and one that runs
on UNIX. The Windows simulator is available on the website and on the CD-
ROM. Students who would rather use the UNIX version can download and install
the software from the web at no charge.
Students use the simulator to test and debug programs written in LC-2
machine language and in LC-2 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-2 machine language and assembly language
programming assignments, which are essential for students to master the concepts
presented throughout the first 10 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 Is. We go through the
process of assembly step-by-step for a very simple LC-2 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 the
xxii preface to the first edition
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 Rl, R2, R3 than with
0001001010000011.
Chapter 8 deals with physical input (from a keyboard) and output (to a mon-
itor). Chapter 9 deals with TRAPs to the operating system, and subroutine calls
and returns. Students study the operating system routines (written in LC-2 code)
for carrying out physical I/O invoked by the TRAP instruction.
The first half of the book concludes with Chapter 10, a treatment of stacks
and data conversion at the LC-2 level, and a comprehensive example that makes
use of both. The example is the simulation of a calculator, which is implemented
by a main program and 11 subroutines.
The Language C
From there, we move on to C. The C programming language occupies the second
half of the book. By the time the student gets to C, he/she has an understanding
of the layers below.
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 programming concepts are
mastered, it is a short step for students to learn more advanced concepts such as
objects and abstraction.
Each time a new construct in C is introduced, the student is shown the LC-2
code that a compiler would produce. We cover the basic constructs of C (vari-
ables, operators, control, and functions), pointers, recursion, arrays, structures,
I/O, complex data structures, and dynamic allocation.
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-2
code is used to demonstrate how each C construct affects the machine at the lower
levels.
In Chapter 14, students are exposed to techniques for debugging high-level
source code. Chapter 15 introduces functions in C. Students are not merely
exposed to the syntax of functions. Rather they learn how functions are actually
executed using a run-time stack. A number of examples are provided.
Chapter 16 teaches recursion, using the student's newly gained knowledge of
functions, activation records, and the run-time stack. Chapter 17 teaches pointers
and arrays, relying heavily on the student's understanding of how memory is
organized. Chapter 18 introduces the details of I/O functions in C, in particular,
xxii preface to the first edition
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 concludes the coverage of C with structures,
dynamic memory allocation, and linked lists.
Along the way, we have tried to emphasize good programming style and
coding 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 17) 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 16), he/she has already encountered all the underpinnings. Students
understand how stacks work at the machine level (Chapter 10), and they under-
stand the call/return mechanism from their LC-2 machine language programming
experience, and the need for linkages between a called program and the return to
the caller (Chapter 9). From this foundation, it is not a large step to explain func-
tions by introducing run-time activation records (Chapter 15), 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.
Horn to Use This Booh
We have discovered over the past two years that there are many ways the material
in this book can be presented in class effectively. We suggest six presentations
below:
1. The Michigan model. First course, no formal prerequisites. Very intensive,
this course covers the entire book. We have found that with talented, very
highly motivated students, this works best.
2. Normal usage. First course, no prerequisites. This course is also intensive,
although less so. It covers most of the book, leaving out Sections 10.3 and
10.4 of Chapter 10, Chapters 16 (recursion), 18 (the details of C I/O), and
19 (data structures).
3. 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. In this
second course, the entire book is covered, spending the first two-thirds of
the semester on the first 10 chapters, and the last one-third of the semester
on the second half of the book. The second half of the book can move
more quickly, given that it follows both Chapters 1-10 and the
preface to the first edition xxi
introductory programming course, which the student has already taken.
Since students have experience with programming, lengthier
programming projects can be assigned. This model allows students who
were introduced to programming via an object-oriented language to pick
up C, which they will certainly need if they plan to go on to advanced
software courses such as operating systems.
4. Two quarters. 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 fcr Chapters 11-19.
5. Two semesters. Perhaps the optimal use of the book. A two-semester
sequence for freshmen. No formal prerequisites. First semester, Chapters
1-10, with supplemental material from Appendix C, the Microarchitecture
of the LC-2. Second semester, Chapters 11-19 with additional substantial
programming projects so that the students can solidify the concepts they
learn in lectures.
6. A sophomore course in computer hardware. Some universities have found
the book useful for a sophomore level breadth-first survey of computer
hardware. They wish to introduce students in one semester to number
systems, digital logic, computer organization, machine language and
assembly language programming, finishing up with the material on stacks,
activation records, recursion, and linked lists. The idea is to tie the
hardware knowledge the students have acquired in the first part of the
course to some of the harder to understand concepts that they struggled
with in their freshman programming course. We strongly believe the better
paradigm is to study the material in this book before tackling an
object-oriented language. Nonetheless, we have seen this approach used
successfully, where the sophomore student gets to understand the concepts
in this course, after struggling with them during the freshman year.
Some Observations
Understanding, Not Memorizing
Since the course builds from the bottom up, we have found that less memorization
of seemingly arbitary 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 understanding 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 component of the student's program, so the student
Another Random Scribd Document
with Unrelated Content
Introduction to Computing Systems From bits and gates to C and beyond 2nd International Edition Yale Patt
Introduction to Computing Systems From bits and gates to C and beyond 2nd International Edition Yale Patt
Introduction to Computing Systems From bits and gates to C and beyond 2nd International Edition Yale Patt
THE HITTITE EMPIRE. 93 his shoulder ; facing them on the
eastern wall are two reliefs of strange character. One of them depicts
the youthful god, whose name perhaps was Attys, embracing with
his left arm the eunuch-priest, above whose head is engraved the
strange symbol that has been already described. The other
represents a god's head crowned with the peaked tiara, and
supported on a double-headed lion, which again stands on the
hinder feet of two other lions, whose heads rest on a column or
stem. All these sculptures were once covered with stucco, and thus
preserved from the action of the weather. It is evident that in these
two mountain recesses we have a sanctuary, the forms and symbols
of whose deities were sculptured on its walls of living rock. It was a
sanctuary too holy to be confined within the walls of the city, and
the supreme deities to whom it was dedicated were a god and a
goddess, served by a multitude of male and female priests. In fact,
as Prof. Perrot remarks, Boghaz Keui must have been a sacred city
like Komana, whose citizens were consecrated to the chief divinities
adored by the Hittites, and were governed by a high-priest. It was
as much a ' Kadesh ' or ' Hierapolis,' as much a ' holy city,' as
Carchemish itself. It is not its sculptures only which prove to us that
it was a city of the Hittites. The figures of the deities have attached
to them, as at Eyuk, the same hieroglyphs as those which meet us in
the inscriptions of Hamath and Aleppo, of Carchemish and Merash,
and within its walls, southward of the ruins of its palace, Prof. Perrot
discovered a long text of nine or ten lines cut out of the rock, and
though worn and disfigured by time and weather, still showing the
forms of many
94 THE HITTITES. Hittite characters. So far as can be
judged from a photograph of it he has published, the forms are the
same as those which are found on the Hittite monuments of Syria.
Tedious as all these details may seem to be, it has been necessary to
give them, since they tell us what was the appearance and
construction of a Hittite city, a Hittite palace, and the interior of a
Hittite temple. The discoveries recently made in the Hittite districts
south of the Taurus, show us that here too the palaces and temples
were like those of Eyuk and Boghaz Keui. Here too we find the same
dados sculptured with the same figures dressed in the same
costume ; here too we meet with the same lions, and the same
winged deities standing on the backs of animals. A photograph of a
piece of sculpture on a block of basalt at Carchemish, taken by Dr.
Gwyther, might have been taken at Boghaz Keui. The art, the forms,
and the symbolism are all the same. The high-road from Boghaz
Keui to Merash must have passed through the defile of Ghurun,
where Sir Charles Wilson discovered Hittite inscriptions carved upon
the cliff. But there may have been a second road which led through
Kaisariyeh, the modern capital of Kappadokia, southward to Bor or
Tyana, where Prof. Ramsay found a Hittite text, and from thence to
the silver mines of the Bulgar Dagh. The bas-reliefs of Ibreez are not
far distant from the famous Cilician gates which led the traveller
from the great central plateau of Asia Minor to Tarsus and the sea. It
would seem that the silver mines of the Bulgar Dagh were first
worked by Hittite miners. Silver had a special attraction for the
Hittite race. The material
THE HITTITE EMPIRE. 95 on which the Hittite version of
the treaty between the Hittite king of Kadesh and the Egyptian
Pharaoh was written was a tablet of that metal. That such tablets
were in frequent use, results from the fact that nearly all the Hittite
inscriptions known to us are not incised, but cut in relief upon the
stone. It is therefore obvious that the Hittites must have first
inscribed their hieroglyphs upon metal, rather than upon wood or
stone or clay ; it is only in the case of metal that it is less laborious
to hammer or cast in relief than to cut the metal with a graving tool,
and nothing can prove more clearly how long accustomed the Hittite
scribes must have been to doing so, than their imitation of this work
in relief when they came to write upon stone. It is possible that most
of the silver of which they made use came from the Bulgar Dagh.
The Hittite inscription found near the old mines of these mountains
by Mr. Davis, proves that they had once occupied the locality. It is
even possible that their settlement for a time in Lydia was also
connected with their passion for 'the bright metal.' At all events the
Gumush Dagh, or ' Silver Mountains,' lie to the south of the Pass of
Karabel, and traces of old workings can still be detected in them.
However this may be, the Hittite monuments of Asia Minor confirm
in a striking way the evidence of the Egyptian inscriptions. They
show us that the Hittites worked for silver in the mountains which
looked down upon the Cilician plain, from whence the influence of
their art and writing extended into the plain itself. They further show
that the central point of Hittite power was a square on either side of
the Taurus range, which included Carchemish and Komagene in the
south,
g6 THE HITTITES. the district eastwards of the Halys on
the north, and the country of which Malatiyeh was the capital in the
east. The Hittite tribes, in fact, were mountaineers from the plateau
of Kappadokia who had spread themselves out in all directions. A
time came when, under the leadership of powerful princes, they
marched along the two high-roads of Asia Minor and established
their supremacy over the coast-tribes of the far west. The age to
which this military empire belongs is indicated by the Egyptian
character of the so-called image of Niobe on the cliff of Sipylos, as
well as by the sphinxes which guarded the entrance to the palace of
Eyuk. It goes back to the days when the rulers of Kadesh could
summon to their aid the vassal-chieftains of the iEgean coast. The
monuments the Hittites have left behind them in Asia Minor thus
bear the same testimony as the records of Egypt. The people to
whom Uriah, and it may be Bath-sheba, belonged, not only had
contended on equal terms with one of the greatest of Egyptian kings
; they had carried their arms through the whole length of Asia Minor,
they had set up satraps in the cities of Lydia, and had brought the
civilisation of the East to the barbarous tribes of the distant West.
CHAPTER V. THE HITTITE CITIES AND RACE. OF the
history of the ' White Syrians ' or Hittites who lived in the land of
Pteria, near the Halys, we know nothing at present beyond what we
can gather from the ruins of their stronghold at Boghaz Keui and
their palace at Eyuk. The same is the case with the Hittite tribes of
Malatiyeh and Komag£ne When the inscription which adorns the
body of a stone lion found at Merash can be deciphered, it will
doubtless cast light on the early history of the city ; at present we do
not know even its ancient name. It is not until we leave the
mountainous region originally occupied by the Hittite race, and
descend into the valleys of Syria, that the annals of their neighbours
begin to tell us something about their fortunes and achievements.
The history of their two southern capitals, Carchemish and Kadesh,
broken and imperfect though it may be, is not an utter blank. The
site of Carchemish had long been looked for in vain. At one time it
was identified with the Kirkesion or Circesium of classical geography,
built at the confluence of the Khabour and the Euphrates. But the
Assyrian name of Kirkesion was Sirki, and its position did not agree
with that assigned to ' Gargamis ' or Carchemish in the Assyrian
texts. Professor Maspero subsequently placed the latter at Membij,
the ancient Mabog or Hierapolis, on the strength of the evidence
furnished by G
98 THE HITTITES. classical authors and the Egyptian
monuments ; but the ruins of Membij contain nothing earlier than
the Greek period, and their position on a rocky plateau at a distance
from the Euphrates, is inconsistent with the fact known to us from
the Assyrian inscriptions, that Carchemish commanded the fords
over the Euphrates. To Mr. Skene, for many years the English consul
at Aleppo, is due the credit of first discovering the true site of the
old Hittite capital. On the western bank of the Euphrates, midway
between Birejik and the mouth of the Sajur, rises an artificial mound
of earth, under which ruins and sculptured blocks of stone had been
found from time to time. It was known as Jerablus, or Kalaat
Jerablus, ' the fortress of Jerablus,' sometimes wrongly written
Jerabis ; and in the name of Jerablus Mr. Skene had no difficulty in
recognising an Arab corruption of Hierapolis. In the Roman age the
name of Hierapolis or ' Holy City ' had been transferred to its
neighbour Membij, which inherited the traditions and religious fame
of the older Carchemish ; but when the triumph of Christianity in
Syria brought with it the fall of the great temple of Membij, the
name disappeared from the later city, and was remembered only in
connection with the ruins of the ancient Carchemish. Two years after
Mr. Skene's discovery, Mr. George Smith visited Carchemish on his
last ill-fated journey from which he never returned, and recognised
at once that Mr. Skene's identification was right. The position of
Jerablus suited the requirements of the Assyrian texts, it lay on the
high-road which formerly led from east to west, and among its ruins
was an inscription in Hittite characters. Not long afterwards there
were brought to the British Museum the bronze bands which once
adorned
THE HITTITE CITIES AND RACE. 99 the gates of an
Assyrian temple, and on one of these is a picture in relief of
Carchemish as it looked in the days of Jehu of Israel. The Euphrates
is represented as running past its walls, thus conclusively showing
that Jerablus, and not Membij, must be the site on which it stood.
The site was bought by Mr. Henderson, Mr. Skene's successor at
Aleppo, and the money was invested by the former owner in the
purchase of a cow. The mighty were fallen indeed, when the Hittite
capital which had resisted the armies of Egypt and Assyria was
judged to be worth no more than the price of a beast of the field. In
1878 Mr. Henderson was employed by the Trustees of the British
Museum in excavating on the spot ; but no sufficient supervision was
exercised over the workmen, and though a few remains of Hittite
sculpture and writing found their way to London, much was left to
be burned into lime by the natives or employed in the construction
of a mill. The ancient city was defended on two sides by the
Euphrates, and was exposed only on the north and west. Here,
however, an artificial canal had been cut, on either side of which was
a fortified wall. The mound which had first attracted Mr. Skene's
attention marks the site of the royal palace, where the excavators
found the remains of a dado like that of Eyuk, the face of the stones
having been sculptured into the likeness of gods and men. The men
were shod with boots with upturned ends, that unfailing
characteristic of Hittite art. Carchemish enjoyed a long history. When
first we hear of it in the Egyptian records it was already in Hittite
hands. Thothmes III. fought beneath its walls, and his bravest
warriors plunged into the Euphrates in G 2
100 THE HITTITES. their eagerness to capture the foe.
Tiglath-pileser I. had seen its walls from the opposite shore of the
Euphrates, but had not ventured to approach them. Assurnatsir-pal
and his son Shalmaneser had received tribute from its king, and
when it finally surrendered to the armies of Sargon it was made the
seat of an Assyrian satrap. The trade which had flowed through it
continued to pour wealth into the hands of its merchants, and the '
maneh of Carchemish ' remained a standard of value. When Egypt
made her final struggle for supremacy in Asia, it was under the walls
of Carchemish that the decisive struggle was fought. The battle of
Carchemish in B.C. 604 drove Necho out of Syria and Palestine, and
placed the destinies of the chosen people in the hands of the
Babylonian king. It is possible that the ruin of Carchemish dates
from the battle. However that may be, long before the beginning of
the Christian era it had been supplanted by Mabog or Membij, and
the great sanctuary which had made it a 1 holy city ' was transferred
to its rival and successor. Like Carchemish, Kadesh on the Orontes,
the most southern capital the Hittites possessed, was also a ' holy
city.' Pictures of it have been preserved on the monuments of
Ramses II. We gather from them that it stood on the shore of the
Lake of Horns, still called the ' Lake of Kadesh/ at the point where
the Orontes flowed out of the lake. The river was conducted round
the city in a double channel, across which a wide bridge was thrown,
the space between the two channels being apparently occupied by a
wall. Kadesh must have been one of the last conquests made by the
Hittites in Syria, and their retention of it was the visible sign of their
supremacy over Western
THE HITTITE CITIES AND RACE. lOI Asia. We do not know
when they were forced to yield up its possession to others. As has
been pointed out, the correct reading of 2 Sam. xxiv. 6 informs us
that the northern limit of the kingdom of David was formed by ' the
Hittites of Kadesh/ ! the entering in of Hamath,' as it seems to be
called elsewhere. In the age of David, accordingly, Kadesh must still
have been in their hands, but it had already ceased to be so when
the Assyrian king Shalmaneser III. led his armies to the west. No
allusion to the city and its inhabitants occurs in the Assyrian
inscriptions, and we may conjecture that it had been destroyed by
the Syrians of Damascus. As Membij took the place of Carchemish,
so Emesa or Horns took the place of Kadesh. We have seen that the
Hittites were a northern race. Their primitive home probably lay on
the northern side of the Taurus. What they were like we can learn
both from their own sculptures and from the Egyptian monuments,
which agree most remarkably in the delineation of their features.
The extraordinary resemblance between the Hittite faces drawn by
the Egyptian artists and those depicted by themselves in their bas-
reliefs and their hieroglyphs, is a convincing proof of the faithfulness
of the Egyptian representations, as well as of the identity of the
Hittites of the Egyptian inscriptions with the Hittites of Carchemish
and Kappadokia. It must be confessed that they were not a
handsome people. They were short and thick of limb, and the front
part of their faces was pushed forward in a curious and somewhat
repulsive way. The forehead retreated, the cheek-bones were high,
the nostrils were large, the upper lip protrusive. They had, in fact,
according to the craniologists, the characteristics of a Mongoloid
race.
102 THE HITTITES. Like the Mongols, moreover, their skins
were yellow and their eyes and hair were black. They arranged the
hair in the form of a ' pig-tail,' which characterises them on their
own and the Egyptian monuments quite as much as their snow-
shoes with upturned toes. In Syria they doubtless mixed with the
Semitic race, and the further south they advanced the more likely
they were to become absorbed into the native population. The
Hittites of Southern Judah have Semitic names, and probably spoke
a Semitic language. Kadesh continued to bear to the last its Semitic
title, and among the Hittite names which occur further north there
are several which display a Semitic stamp. In the neighbourhood of
Carchemish Hittites and Arameans were mingled together, and
Pethor was at once a Hittite and an Aramean town. In short, the
Hittites in Syria were like a conquering race everywhere ; they
formed merely the governing and upper class, which became smaller
and smaller the further removed they were from their original seats.
Like the Normans in Sicily or the Etruscans in ancient Italy, they
tended gradually to disappear or else to be absorbed into the
subject race. It was only in their primitive homes that they survived
in their original strength and purity, and though even in Kappadokia
they lost their old languages, adopting in place of them first
Aramaic, then Greek, and lastly Turkish, we may still observe their
features and characteristics in the modern inhabitants of the Taurus
range. Even in certain districts of Kappadokia their descendants may
still be met with. ' The type,' says Sir Charles Wilson, ' which is not a
beautiful one, is still found in some parts of Kappadokia, especially
amongst the people living in the extraordinary subterranean
THE HITTITE CITIES AND RACE. 103 towns which I
discovered beneath the great plain northwest of Nigdeh.' The
characteristics of race, when once acquired, seem almost indelible ;
and it is possible that, when careful observations can be made, it will
be found that the ancient Hittite race still survives, not only in
Eastern Asia Minor, but even in the southern regions of Palestine.
CHAPTER VI. HITTITE RELIGION AND ART. LUCIAN, or
some other Greek writer who has usurped his name, has left us a
minute account of the great temple of Mabog as it existed in the
second century of the Christian era. Mabog, as we have seen, was
the successor of Carchemish ; and there is little reason to doubt that
the pagan temple of Mabog, with all the rites and ceremonies that
were carried on in it, differed but little from the pagan temple of the
older Carchemish. It stood, we are told, in the very centre of the '
Holy City.' It consisted of an outer court and an inner sanctuary,
which again contained a Holy of Holies, entered only by the high-
priest and those of his companions who were ' nearest the gods.'
The temple was erected on an artificial mound or platform, more
than twelve feet in height, and its walls and ceiling within were
brilliant with gold. Its doors were also gilded, but the Holy of Holies
or innermost shrine was not provided with doors, being separated
from the rest of the building, it would seem, like the Holy of Holies in
the Jewish temple, by a curtain or veil. On either side of the
entrance was a cone-like column of great height, a symbol of the
goddess of fertility, and in the outer court a large altar of brass. To
the left of the latter was an image of ' Semiramis,' and not far off a
great
HITTITE RELIGION AND ART. 105 'sea' or Make,' containing
sacred fish. Oxen, horses, eagles, bears, and lions were kept in the
court, as being sacred to the deities worshipped within. On entering
the temple the visitor saw on his left the throne of the Sun-god, but
no image, since the Sun and Moon alone of the gods had no images
dedicated to them. Beyond, however, were the statues of various
divinities, among others the wonder-working image of a god who
was believed to deliver oracles and prophecies. At times, it was said,
the image moved of its own accord, and if not lifted up at once by
the priests, began to perspire. When the priests took it in their
hands, it led them from one part of the temple to the other, until the
high-priest, standing before it, asked it questions, which it answered
by driving its bearers forward. The central objects of worship,
however, were the golden images of two deities, whom Lucian
identifies with the Greek Hera and Zeus, another figure standing
between them, on the head of which rested a golden dove. The
gcddess, who blazed with precious stones, bore in her hand a
sceptre and on her head that turreted or mural crown which
distinguishes the goddesses of Boghaz Keui. Like them, moreover,
she was supported on lions, while her consort was carried by bulls.
In him we may recognise the god who at Boghaz Keui is advancing
to meet the supreme Hittite goddess. In the Egyptian text of the
treaty between Ramses and the king of Kadesh, the supreme Hittite
god is called Sutekh, the goddess being Antarata, or perhaps
Astarata. In later days, however, the goddess of Carchemish was
known as Athar-'Ati, which the Greeks transformed into Atargatis
and Derketo. Derketo was fabled to be the mother of Semiramis, in
whom Greek
106 THE HITTITES. legend saw an Assyrian queen ; but
Semiramis was really the goddess Istar, called Ashtoreth in Canaan,
and Atthar or Athar by the Arameans, among whom Carchemish was
built. Derketo was, therefore, but another form of Semiramis, or
rather but another name under which the great Asiatic goddess was
known. The dove was sacred to her, and this explains why an image
of the dove was placed above the head of the third image in the
divine triad of Mabog. The temple was served by a multitude of
priests. More than 300 took part in the sacrifices on the day when
Lucian saw it. The priests were dressed in v/hite, and wore the skull-
cap which we find depicted on the Hittite monuments. The high-
priest alone carried on his head the lofty tiara, which the sculptures
indicate was a prerogative of gods and kings. Prominent among the
priests were the Galli or eunuchs, who on the days of festival cut
their arms and scourged themselves in honour of their deities. Such
actions remind us of those priests of Baal who ( cut themselves after
their manner with knives and lancets, till the blood gushed out upon
them.' Twice a year a solemn procession took place to a small chasm
in the rock under the temple, where, it was alleged, the waters of
the deluge had been swallowed up, and water from the sea was
poured into it. It is to this pit that Melito, a Christian writer of Syria,
alludes when he says that the goddess Simi, the daughter of the
supreme god Hadad, put an end to the attacks of a demon by filling
with sea water the pit in which he lived. But in Lucian's time the
demon was regarded as the deluge, and the account of the deluge
given to the Greek writer agrees so closely with that which we read
HITTITE RELIGION AND ART. 107 in Genesis as to make it
clear that it had been borrowed by the priests of Hierapolis from the
Hebrew Scriptures. It is probable, however, that the tradition itself
was of much older standing, and had originally been imported from
Babylonia. At all events the hero of the deluge was called Sisythes, a
modification of the name of the Chaldaean Noah, while Major
Conder found a place in the close neighbourhood of Kadesh which is
known as ' the Ark of the Prophet Noah/ and close at hand a spring
termed the Tannur or ' Oven,' out of which, according to
Mohammedan belief, the waters of the flood gushed forth. But there
were many other festivals at Mabog besides that which
commemorated the subsidence of the deluge. Pilgrims flocked to it
from all parts — Arabia, Palestine, Kappadokia, Babylonia, even
India. They were required to drink water only, and to sleep on the
ground. Numerous and rich were the offerings which they brought to
the shrine, and once arrived there were called upon to offer
sacrifices. Goats and sheep were the most common victims, though
oxen were also offered. The only animal whose flesh was forbidden
to be either sacrificed or eaten was the swine ; as among the Jews,
it was regarded as unclean. After being dedicated in the court of the
temple the animal was usually led to the house of the offerer, and
there put to death ; sometimes, however, it was killed by being
thrown from the entrance to the temple. Even children were
sacrificed by their parents in this way, after first being tied up in
skins and told that they were 'not children but oxen.' Different
stories were current as to the foundation of the temple. There were
some who affirmed that
108 THE HITTITES. Sisythes had built it after the deluge
over the spot where the waters of the flood had been swallowed up
by the earth. It is possible that this was the legend originally
believed in Mabog before the traditions of Carchemish had been
transferred to it. It seems to be closely connected with the local
peculiarities of the site. The other legends had doubtless had their
origin in the older Hierapolis. According to one of them, the temple
had been founded by Semiramis in honour of her mother Derketo,
half woman and half fish, to whom the fish in the neighbouring lake
were sacred. Another account made Attys its founder, and the
goddess to whom it was dedicated the divinity called Rhea by the
Greeks. Derketo and Rhea, however, are but different names of the
same deity, who was known as Kybele or Kybebe in Phrygia, and
honoured with the title of 'the Great Mother.' Her images were
covered with breasts, to symbolise that she was but mother-earth,
from whom mankind derived their means of life. Her attributes were
borrowed from those of the Babylonian Istar, the Ashtoreth of
Canaan ; even the form assigned to her was that of the Babylonian
Istar, as we learn from a bas-relief discovered at Carchemish, where
she is represented as naked, a lofty tiara alone excepted, with the
hands upon the breasts and a wing rising behind each shoulder. She
was, in fact, a striking illustration of the influence exerted upon the
Hittites, and through them upon the people of Asia Minor, by
Babylonian religion and worship. Even in Lydia a stone has been
found on which her image is carved in a rude style of art, but similar
in form to the representations of her in the basrelief of Carchemish
and the cylinders of ancient Chaldaea.
HITTITE RELIGION AND ART. 109 This stone, like the
seated figure on Mount Sipylos, is a witness that her cult was carried
westward by the Hittite armies. Later tradition preserved a
reminiscence of the fact. The Lydian hero Kayster was said to have
gone to Syria, and there had Derketo for his bride, while on the
other hand it was a Lydian, Mopsos, who was believed to have
drowned the goddess Derketo in the sacred lake of Ashkelon. We
have here, it may be, recollections of the days when Lydian soldiers
marched against Egypt under the leadership of Hittite princes, and
learnt to know the name and the character of Athar-'Ati, the goddess
of Carchemish. The Babylonian Istar was accompanied by her son
and bridegroom Tammuz, the youthful Sun-god, the story of whose
untimely death made a deep impression on the popular mind. Even
in Jerusalem Ezekiel saw the women weeping for the death of
Tammuz within the precincts of the temple itself ; and for days
together each year in the Phoenician cities the festival of his death
and resurrection were observed with fanatic zeal. In Syria he was
called Hadad, and identified with the god Rimmon, so that Zechariah
(xii. 11) speaks of the mourning for Hadad-Rimmon in the valley of
Megiddo. At Hierapolis and Aleppo also he was known as Hadad or
Dadi, while throughout Asia Minor he was adored under the name of
Attys, ' the shepherd of the bright stars/ The myth which told of his
death underwent a slight change of form among the Hittites, and
through them among the tribes of Asia Minor. He is doubtless the
young god who on the rocks of Boghaz Keui appears behind the
mother-goddess, riding like her on the back of a panther or lion. The
people of Mabog did not forget that their temple
IIO THE HITTITES. was but the successor of an older one,
and that Carchemish had once been the ' Holy City' of Northern
Syria. The legends, therefore, which referred to the foundation of
the sanctuary were said to relate to one which had formerly existed,
but had long since fallen into decay. The origin of the temple visited
by Lucian was ascribed to a certain ' Stratonike, the wife of the
Assyrian king.' But Stratonike is merely a Greek transformation of
some Semitic epithet of 'Ashtoreth,' and marks the time when the
Phoenician Ashtoreth took the place of the earlier Athar-'Ati. A
strange legend was told of the youthful Kombabos, who was sent
from Babylon to take part in the building of the shrine. Kombabos
was but Tammuz under another name, just as Stratonike was Istar,
and the legend is chiefly interesting as testifying to the religious
influence once exercised by the Babylonians upon the Hittite people.
Semiramis may turn out to have been the Hittite name of the
goddess called Athar-'Ati by the Aramean inhabitants of Hierapolis.
In this case the difficulty of accounting for the existence of the two
names would have been solved in the old myths by making her the
daughter of Derketo. But while Derketo was a fishgoddess,
Semiramis was associated with the dove, like the Ashtoreth or
Aphrodite who was worshipped in Cyprus. The symbol of the dove
had been carried to the distant West at an early period. Among the
objects found by Dr. Schliemann in the prehistoric tombs of Mykenae
were figures in gold-leaf, two of which represented a naked goddess
with the hands upon the breasts and doves above her, while the
third has the form of a temple, on the two pinnacles of which are
seated two doves. Considering how intimately the prehistoric art of
My 
HITTITE RELIGION AND ART. Ill kense seems to have been
connected with that of Asia Minor, it is hardly too much to suppose
that the symbol of the dove had made its way across the ^Egean
through the help of the Hittites, and that in the pinnacled temple of
Mykenae, with its two doves, we may see a picture of a Hittite
temple in Lydia or Kappadokia. The legends reported by Lucian
about the foundation of the temple of Mabog all agreed that it was
dedicated to a goddess. The ' Holy City' was under the protection,
not of a male but of a female divinity, which explains why it was that
it was served by eunuch priests. If Attys or Hadad was worshipped
there, it was in right of his mother ; the images of the other gods
stood in the temple on sufferance only. The male deity whom the
Greek author identified with Zeus must have been regarded as
admitted by treaty or marriage to share in the honours paid to her. It
must have been the same also at Boghaz Keui. Here, too, the most
prominent figure in the divine procession is that of the Mother-
goddess, who is followed by her son Attys, while the god, whose
name may be read Tar or Tarku, 'the king,' and who is the Zeus of
Lucian, advances to meet her. In Cilicia and Lydia this latter god
seems to have been known as Sandan. He is called on coins the '
Baal of Tarsos,' and he carries in his hand a bunch of grapes and a
stalk of corn. We may see his figure engraved on the rock of Ibreez.
Here he wears on his head the pointed Hittite cap, ornamented with
hornlike ribbons, besides the short tunic and boots with upturned
ends. On his wrists are bracelets, and earrings hang from his ears.
Sandan was identified with the Sun, and hence it
112 THE HITTITES. happened that when a Semitic
language came to prevail in Cilicia he was transformed into a
supreme Baal. The same transformation had taken place centuries
before in the Hittite cities of Syria. Beside the Syrian goddess Kes,
who is represented as standing upon a lion, like the great goddess of
Carchemish, the Egyptian monuments tell us of Sutekh, who stands
in the same relation to his Hittite worshippers as the Semitic Baal
stood to the populations of Canaan. Sutekh was the supreme Hittite
god, but at the same time he was localised in every city or state in
which the Hittites lived. Thus there was a Sutekh of Carchemish and
a Sutekh of Kadesh, just as there was a Baal of Tyre and a Baal of
Tarsos. The forms under which he was worshipped were manifold,
but everywhere it was the same Sutekh, the same national god. It
would seem that the power of Sutekh began to wane after the age
of Ramses, and that the goddess began to usurp the place once held
by the god. It is possible that this was due to Babylonian and
Assyrian influence. At any rate, whereas it is Sutekh who appears at
the head of the Hittite states in the treaty with Ramses, in later days
the chief cult of the ' Holy Cities' was paid to the Mother-goddess.
His place was taken by the goddess at Carchemish as well as at
Mabog, at Boghaz Keui as well as at Komana. In the Kappadokian
Komana the goddess went under the name of Ma. She was served
by 6000 priests and priestesses, the whole city being dedicated to
her service. The place of the king was occupied by the Abakles or
high-priest. We have seen that the sculptures of Boghaz Keui give us
reason to believe that the same was also the case in Pteria; we
know that it was so in
HITTITE RELIGION AND ART. 113 other 'Holy Cities' of Asia
Minor. At Pessinus in Phrygia, where lions and panthers stood beside
the goddess, the whole city was given up to her worship, under the
command of the chief Gallos or priest ; and on the shores of the
Black Sea the Amazonian priestesses of Kybele, who danced in
armour in her honour, were imagined by the Greeks to constitute the
sole population of an entire country. At Ephesos, in spite of the
Greek colony which had found its way there, the worship of the
Mother-goddess continued to absorb the life of the inhabitants, so
that it still could be described in the time of St. Paul as a city which
was 'a worshipper of the great goddess.' Here, as at Pessinus, she
was worshipped under the form of a meteoric stone 'which had
fallen from heaven.' We may regard these ' Holy Cities,' placed under
the protection of a goddess and wholly devoted to her worship, as
peculiarly characteristic of the Hittite race. Their two southern
capitals, Kadesh and Carchemish, were cities of this kind, and their
stronghold at Boghaz Keui was presumably also a consecrated place.
Their progress through Asia Minor was characterised by the rise of
priestly cities and the growth of a class of armed priestesses.
Komana in Kappadokia, and Ephesos on the shores of the yEgean,
are typical examples of such holy towns. The entire population
ministered to the divinity to whom the city was dedicated, the
sanctuary of the deity stood in its centre, and the chief authority was
wielded by a high-priest. If a king existed by the side of the priest,
he came in course of time to fill a merely subordinate position.
These 'Holy Cities' were also ' Asyla' or Cities of Refuge. The
homicide could escape to them, and be H
114 THE HITTITES. safe from his pursuers. Once within the
precincts of the city and the protection of its deity, he could not be
injured or slain. But it was not only the man who had slain another
by accident who could thus claim an ' asylum' from his enemies. The
debtor and the political refugee were equally safe. Doubtless the
right of asylum was frequently abused, and real criminals took
advantage of regulations which were intended to protect the
unfortunate in an age of lawlessness and revenge. But the institution
on the whole worked well, and, while it strengthened the power of
the priesthood, it curbed injustice and restrained violence. Now the
institution of Cities of Refuge did not exist only in Asia Minor and in
the region occupied by the Hittites. It existed also in Palestine, and it
seems not unlikely that it was adopted by the great Hebrew
lawgiver, acting under divine guidance, from the older population of
the country. The Hebrew cities of refuge were six in number. Gne of
them was ' Kedesh in Galilee,' whose very name declares it to have
been a ' Holy City,' like Kadesh on the Orontes, while another was
the ancient sanctuary of Hebron, once occupied by Hittites and
Amorites. Shechem, the third city of refuge on the western side of
the Jordan, had been taken by Jacob ' out of the hand of the
Amorite' (Gen. xlviii. 22) ; and the other three cities were all on the
eastern side of the Jordan, in the region so long held by Amorite
tribes. We are therefore tempted to ask whether these cities had not
already been 'asyla' or cities of refuge long before Moses was
enjoined by God to make them such for the Israelitish conquerors of
Palestine. Closely connected with Hittite religion was Hittite art.
Religion and art have been often intertwined to 
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookfinal.com

More Related Content

PDF
Introduction to Computing Systems From bits and gates to C and beyond 2nd Int...
PDF
Introduction To Computing Systems From Bits And Gates To C And Beyond 2nd Int...
PDF
Introduction to Computing Systems: From Bits & Gates to C & Beyond 3rd Editio...
PDF
Download full ebook of Computer Systems 5th Edition (eBook PDF) instant downl...
PDF
Computer Systems A Programmers Perspective 2nd Edition 2nd Edition Bryant
PPTX
.Comp Org and Arch All_Slide_1711695396000.pptx
PPTX
Ch01.pptxxxxxxxxxcxcxcxxccxxxxxxxxxxxcccccc
PPTX
Ch01.pptxcomputer organization and architecture schools
Introduction to Computing Systems From bits and gates to C and beyond 2nd Int...
Introduction To Computing Systems From Bits And Gates To C And Beyond 2nd Int...
Introduction to Computing Systems: From Bits & Gates to C & Beyond 3rd Editio...
Download full ebook of Computer Systems 5th Edition (eBook PDF) instant downl...
Computer Systems A Programmers Perspective 2nd Edition 2nd Edition Bryant
.Comp Org and Arch All_Slide_1711695396000.pptx
Ch01.pptxxxxxxxxxcxcxcxxccxxxxxxxxxxxcccccc
Ch01.pptxcomputer organization and architecture schools

Similar to Introduction to Computing Systems From bits and gates to C and beyond 2nd International Edition Yale Patt (20)

PDF
Computer Organization Basic Processor Structure Gil De Lamadrid
PPTX
ComputerProgrammingCPattPatelChapter.pptx
PPTX
ICT FIRST LECTURE.pptx
PPTX
ch01_inclass_computers_Chapter 1_Welcome Aboard.pptx
PPT
Digital system design using vhdl and verilog
PPT
f37-book-intarch-pres-pt1.ppt
PPT
f37-book-intarch-pres-pt1.ppt
PPT
f37-book-intarch-pres-pt1.ppt
PDF
Electrónica digital: Logicsim
PPTX
F21-LOGIC DESIGN Advanced lec-FOE-CMPN111 SP23.pptx
PPT
Computer architecture
PPT
Computer architecture
PDF
Digital logic and microprocessors
PPT
Chapter1.ppt
PPT
computer logic and digital design chapter 1
PDF
Csc 2313 (lecture 4)
PPTX
0578-computer-fundamentals.pptx
PPTX
Chp 2 and 3.pptx
PPT
RISC-V processor- computer organization and design
PPT
An Introduction to Computer Logic and Digital Design.ppt
Computer Organization Basic Processor Structure Gil De Lamadrid
ComputerProgrammingCPattPatelChapter.pptx
ICT FIRST LECTURE.pptx
ch01_inclass_computers_Chapter 1_Welcome Aboard.pptx
Digital system design using vhdl and verilog
f37-book-intarch-pres-pt1.ppt
f37-book-intarch-pres-pt1.ppt
f37-book-intarch-pres-pt1.ppt
Electrónica digital: Logicsim
F21-LOGIC DESIGN Advanced lec-FOE-CMPN111 SP23.pptx
Computer architecture
Computer architecture
Digital logic and microprocessors
Chapter1.ppt
computer logic and digital design chapter 1
Csc 2313 (lecture 4)
0578-computer-fundamentals.pptx
Chp 2 and 3.pptx
RISC-V processor- computer organization and design
An Introduction to Computer Logic and Digital Design.ppt
Ad

Recently uploaded (20)

PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PPTX
Digestion and Absorption of Carbohydrates, Proteina and Fats
PDF
1_English_Language_Set_2.pdf probationary
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
IGGE1 Understanding the Self1234567891011
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PPTX
Cell Types and Its function , kingdom of life
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
Empowerment Technology for Senior High School Guide
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Trump Administration's workforce development strategy
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
A systematic review of self-coping strategies used by university students to ...
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Digestion and Absorption of Carbohydrates, Proteina and Fats
1_English_Language_Set_2.pdf probationary
Orientation - ARALprogram of Deped to the Parents.pptx
IGGE1 Understanding the Self1234567891011
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Chinmaya Tiranga quiz Grand Finale.pdf
Paper A Mock Exam 9_ Attempt review.pdf.
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
Cell Types and Its function , kingdom of life
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
Empowerment Technology for Senior High School Guide
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Trump Administration's workforce development strategy
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
A systematic review of self-coping strategies used by university students to ...
Ad

Introduction to Computing Systems From bits and gates to C and beyond 2nd International Edition Yale Patt

  • 1. Introduction to Computing Systems From bits and gates to C and beyond 2nd International Edition Yale Patt - Downloadable PDF 2025 https://ebookfinal.com/download/introduction-to-computing-systems-from- bits-and-gates-to-c-and-beyond-2nd-international-edition-yale-patt/ Visit ebookfinal.com today to download the complete set of ebooks or textbooks
  • 2. Here are some recommended products that we believe you will be interested in. You can click the link to download. From Kosovo to Kabul and Beyond Human Rights and International Intervention David Chandler https://ebookfinal.com/download/from-kosovo-to-kabul-and-beyond-human- rights-and-international-intervention-david-chandler/ Introduction to Grid Computing 1st Edition Frederic Magoules https://ebookfinal.com/download/introduction-to-grid-computing-1st- edition-frederic-magoules/ Database Systems Introduction to Databases and Data Warehouses 2nd Edition Nenad Jukic■ https://ebookfinal.com/download/database-systems-introduction-to- databases-and-data-warehouses-2nd-edition-nenad-jukic/ Introduction to Optical Microscopy 2nd Edition Jerome C. Mertz https://ebookfinal.com/download/introduction-to-optical- microscopy-2nd-edition-jerome-c-mertz/
  • 3. Practicing Harm Reduction Psychotherapy An Alternative Approach to Addictions 2nd Edition Patt Denning https://ebookfinal.com/download/practicing-harm-reduction- psychotherapy-an-alternative-approach-to-addictions-2nd-edition-patt- denning/ Introduction to Building Procurement Systems 2nd Edition Dr Jack Masterman https://ebookfinal.com/download/introduction-to-building-procurement- systems-2nd-edition-dr-jack-masterman/ Introduction to High Performance Computing for Scientists and Engineers 1st Edition Georg Hager https://ebookfinal.com/download/introduction-to-high-performance- computing-for-scientists-and-engineers-1st-edition-georg-hager/ Stimuli Responsive Drug Delivery Systems From Introduction to Application 1st Edition Bajpai https://ebookfinal.com/download/stimuli-responsive-drug-delivery- systems-from-introduction-to-application-1st-edition-bajpai/ Structure and Function From clause to discourse and beyond Christopher Butler https://ebookfinal.com/download/structure-and-function-from-clause-to- discourse-and-beyond-christopher-butler/
  • 5. Introduction to Computing Systems From bits and gates to C and beyond 2nd International Edition Yale Patt Digital Instant Download Author(s): Yale Patt, Sanjay Patel ISBN(s): 9780071245012, 0071245014 Edition: 2nd International File Details: PDF, 13.10 MB Year: 2005 Language: english
  • 7. The McGraw-Hill Companies Mc Graw Hill INTRODUCTION TO COMPUTING SYSTEMS: FROM BITS AND GATES TO C AND BEYOND SECOND EDITION International Edition 2005 Exclusive rights by McGraw-Hill Education (Asia), for manufacture and export. This book cannot be re-exported from the country to which it is sold by McGraw-Hill. The International Edition is not available in North America. Published by McGraw-Hill, a business unit of The McGraw-Hill Companies, Inc., 1221 Avenue of the Americas, New York, NY 10020. Copyright © 2004, 2001 by The McGraw-Hill Companies, Inc. All rights reserved. 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 The McGraw- Hill Companies, Inc., 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. 10 09 08 07 06 05 04 03 02 01 20 09 08 07 06 05 04 CTF SEP Cover images: ©Photodisc, AA048376 Green Abstract, AA003317 Circuit Board Detail Library of Congress Control Number: 2003051002 When ordering this title, use ISBN 007-124501-4 Printed in Singapore
  • 8. > > second edition introduction to computing systems from bits and gates to C and beyond Yale N. Patt The University of Texas at Austin Sanjay J. Patel University of Illinois at Urbana-Champaign Mc Graw Hill Higher Education Boston Burr Ridge, IL Dubuque, IA Madison, Wl New York San Francisco St. Louis Bangkok Bogota Caracas Kuala Lumpur Lisbon London Madrid Mexico City Milan Montreal New Delhi Santiago Seoul Singapore Sydney Taipei Toronto
  • 9. 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 Mira and her grandparents, Sharda Patel and Jeram Patel.
  • 10. contents Preface xi Preface to the First Edition 1 Welcome Aboard 1 XVII 2.4.1 Binary to Decimal Conversion 27 2.4.2 Decimal to Binary Conversion 28 1.1 1.2 1.3 1.4 1.5 1.6 1.7 What We Will Try to Do 1 How We Will Get There 2 Two Recurring Themes 3 1.3.1 The Notion of Abstraction 3 1.3.2 Hardware versus Software 5 A Computer System 7 Two Very Important Ideas 9 Computers as Universal Computational Devices 9 How Do We Get the Electrons to Do the Work? 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 Exercises 17 12 The Statement of the Problem 13 The Algorithm 13 The Program 14 The ISA 14 The Microarchitecture 15 The Logic Circuit 16 The Devices 16 Putting It Together 16 2 Bits, Data Types, and Operations 21 2.1 2.2 2.3 2.4 Bits and Data Types 21 2.1.1 The Bit as the Unit of Information 21 2.1.2 Data Types 22 Integer Data Types 23 2.2.1 Unsigned Integers 23 2.2.2 Signed Integers 23 2's Complement Integers 25 Binary-Decimal ..Conversion 27 2.5 Operations on Bits—Part I: Arithmetic 2.5.1 Addition and Subtraction 29 2.5.2 Sign-Extension 30 2.5.3 Overflow 31 2.6 Operations on Bits—Part I I : Logical Operations 33 2.6.1 v The AND Function 33 2.6.2 The OR Function 34 2.6.3 The NOT Function 35 2.6.4 The Exclusive-OR Function 35 2.7 Other Representations 36 2.7.1 The Bit Vector 36 2.7.2 Floating Point Data Type 37 2.7.3 ASCII Codes 40 2.7.4 Hexadecimal Notation 41 Exercises 43 3 Digital Logic Structures 51 3.1 The Transistor 5 1 3.2 Logic Gates 53 3.2.1 The NOT Gate (Inverter) 53 3.2.2 OR and NOR Gates 54 3.2.3 AND and NAND Gates 56 3.2.4 DeMorgan's Law 58 3.2.5 Larger Gates 58 3.3 Combinational Logic Circuits 59 3.3.1 Decoder 59 3.3.2 Mux 60 3.3.3 Full Adder 61 3.3.4 The Programmable Logic Array (PLA) 63 3.3.5 Logical Completeness 64 Basic Storage Elements 64 3.4.1 The R-S Latch 64 3.4.2 The Gated D Latch 66 3.4.3 A Register 66 29 3.4
  • 11. vi Contents 3.5 The Concept of Memory 67 3.5.1 Address Space 68 3.5.2 Addressability 68 3.5.3 A 22 -by-3-Bit Memory 68 3.6 Sequential Logic Circuits 70 3.6.1 A Simple Example: The Combination Lock 71 3.6.2 The Concept of State 72 3.6.3 Finite State Machines 74 3.6.4 An Example: The Complete Implementation of a Finite State Machine 77 3.7 The Data Path of the LC-3 80 Exercises 82 5.4 Control Instructions 130 5.4.1 Conditional Branches 131 5.4.2 An Example 132 5.4.3 Two Methods for Loop Control 135 5.4.4 Example: Adding a Column of Numbers Using a Sentinel 135 5.4.5 The JMP Instruction 136 5.4.6 The TRAP Instruction 137 5.5 Another Example: Counting Occurrences of a Character 138 5.6 The Data Path Revisited 141 5.6.1 Basic Components of the Data Path 141 5.6.2 The Instruction Cycle 144 Exercises 145 4 The von Neumann Model 97 4.1 Basic Components 97 4.1.1 Memory 98 4.1.2 Processing Unit 99 4.1.3 Input and Output 100 4.1.4 Control Unit 100 4.2 The LC-3: An Example von Neumann Machine 101 4.3 Instruction Processing 103 4.3.1 The Instruction 103 4.3.2 The Instruction Cycle 104 4.4 Changing the Sequence of Execution 107 4.4.1 Control of the Instruction Cycle 108 4.5 Stopping the Computer 110 Exercises 111 6 Programming 155 6.1 Problem Solving 155 6.1.1 Systematic Decomposition 155 6.1.2 The Three Constructs: Sequential; Conditional, Iterative 156 6.1.3 LC-3 Control Instructions to Implement the Three Constructs 157 6.1.4 The Character Count Example from Chapter 5, Revisited 158 6.2 Debugging 162 6.2.1 Debugging Operations 163 6.2.2 Examples: Use of the Interactive Debugger 164 Exercises 172 5 The LC-3 115 5.1 The ISA: Overview 115 5.1.1 Memory Organization 116 5.1.2 Registers 116 5.1.3 The Instruction Set 117 5.1.4 Opcodes 117 5.1.5 Data Types 118 5.1.6 Addressing Modes 118 5.1.7 Condition Codes 120 5.2 Operate Instructions 120 5.3 Data Movement Instructions 123 5.3.1 PC-Relative Mode 124 5.3.2 Indirect Mode 125 5.3.3 Base+offset Mode 127 5.3.4 Immediate Mode 128 5.3.5 An Example 129 7 Assembly Language 177 7.1 Assembly Language Programming — Moving Up a Level 177 7.2 An Assembly Language Program 178 7.2.1 Instructions 179 7.2.2 Pseudo-ops (Assembler Directives) 182 7.2.3 Example: The Character Count Example of Section 5.5, Revisited 183 7.3 The Assembly Process 185 7.3.1 Introduction 185 7.3.2 A Two-Pass Process 185 7.3.3 The First Pass: Creating the Symbol Table 186 7.3.4 The Second Pass: Generating the Machine Language Program 187
  • 12. Contents vii 7.4 Beyond the Assembly of a Single Assembly Language Program 188 7.4.1 The Executable Image 189 7.4.2 More than One Object File 189 Exercises 190 8 I/O 199 8.1 I/O Basics 199 8.1.1 Device Registers 199 8.1.2 Memory-Mapped I/O versus Special Input/Output Instructions 200 8.1.3 Asynchronous versus Synchronous 200 8.1.4 Interrupt-Driven versus Polling 202 8.2 Input from the Keyboard 202 8.2.1 Basic Input Registers (the KBDR and the KBSR) 202 8.2.2 The Basic Input Service Routine 202 8.2.3 Implementation of Memory-Mapped Input 203 8.3 Output to the Monitor 204 8.3.1 Basic Output Registers (the DDR and the DSR) 204 8.3.2 The Basic Output Service Routine 205 8.3.3 Implementation of Memory-Mapped Output 206 8.3.4 Example: Keyboard Echo 207 8.4 A More Sophisticated Input Routine 207 8.5 Interrupt-Driven I/O 209 8.5.1 What Is Interrupt-Driven I/O? 209 8.5.2 Why Have Interrupt-Driven I/O? 210 8.5.3 Generation of the Interrupt Signal 211 8.6 Implementation of Memory-Mapped 1/0/ Revisited 214 Exercises 215 9.1.5 TRAP Routines for Handling I/O 225 9.1.6 TRAP Routine for Halting the Computer 225 9.1.7 Saving and Restoring Registers 229 9.2 Subroutines 230 9.2.1 The Call/Return Mechanism 230 9.2.2 The JSR(R) Instruction 232 9.2.3 The TRAP Routine for Character Input, Revisited 233 9.2.4 PUTS: Writing a Character String to the Monitor 235 9.2.5 Library Routines 235 Exercises 240 10 And, Finally . . . The Stack 251 10.1 The Stack: Its Basic Structure 251 10.1.1 The S t a c k - A n Abstract Data Type 251 10.1.2 Two Example Implementations 252 10.1.3 Implementation in Memory 253 10.1.4 The Complete Picture 257 10.2 Interrupt-Driven I/O (Part 2) 258 10.2.1 Initiate and Service the Interrupt 259 10.2.2 Return from the Interrupt 261 10.2.3 An Example 262 10.3 Arithmetic Using a Stack 264 10.3.1 The Stack as Temporary Storage 264 10.3.2 An Example 265 10.3.3 OpAdd, Op Mult, and OpNeg 265 10.4 Data Type Conversion 272 10.4.1 Example: The Bogus Program: 2 + 3 = e 272 10.4.2 ASCII to Binary 273 10.4.3 Binary to ASCII 276 10.5 Our Final Example: The Calculator 278 Exercises 283 9 TRAP Routines and Subroutines 219 9.1 LC-3 TRAP Routines 219 9.1.1 Introduction 219 9.1.2 The TRAP Mechanism 220 9.1.3 The TRAP Instruction 221 9.1.4 The Complete Mechanism 222 11 Introduction to Programming inC 289 11.1 Our Objective 289 11.2 Bridging the Gap 290 11.3 Translating High-Level Language Programs 292
  • 13. viii Contents 11.3.1 Interpretation 292 11.3.2 Compilation 293 11.3.3 Pros and Cons 293 11.4 The C Programming Language 293 11.4.1 The C Compiler 295 11.5 A Simple Example 297 11.5.1 The Function m a i n 297 11.5.2 Formatting, Comments, and Style 299 11.5.3 The C Preprocessor 300 11.5.4 Input and Output 3 0 1 11.6 Summary 3 0 4 Exercises 3 0 5 12 Variables and Operators 307 1 2 . 1 Introduction 3 0 7 12.2 Variables 3 0 8 12.2.1 Three Basic Data Types: int, char, d o u b l e 308 12.2.2 Choosing Identifiers 310 12.2.3 Scope: Local versus Global 3 1 1 12.2.4 More Examples 313 12.3 Operators 3 1 4 12.3.1 Expressions and Statements 315 12.3.2 The Assignment Operator 316 12.3.3 Arithmetic Operators 317 12.3.4 Order of Evaluation 318 12.3.5 Bitwise Operators 319 12.3.6 Relational Operators 320 12.3.7 Logical Operators 322 12.3.8 Increment/Decrement Operators 322 12.3.9 Expressions with Multiple Operators 324 12.4 Problem Solving Using Operators 3 2 4 12.5 Tying it All Together 3 2 6 12.5.1 Symbol Table 326 12.5.2 Allocating Space for Variables 328 12.5.3 A Comprehensive Example 331 12.6 Additional Topics 332 12.6.1 Variations of the Three Basic Types 332 12.6.2 Literals, Constants, and Symbolic Values 334 12.6.3 Storage Class 335 12.6.4 Additional C Operators 336 12.7 Summary 337 Exercises 3 3 8 13 Control Structures 343 1 3 . 1 Introduction 3 4 3 13.2 Conditional Constructs 3 4 4 13.2.1 The if Statement 344 13.2.2 The if-else Statement 347 13.3 Iteration Constructs 3 5 0 13.3.1 The while Statement 350 13.3.2 The for Statement 353 13.3.3 The do-while Statement 358 13.4 Problem Solving Using Control Structures 3 5 9 13.4.1 Problem 1: Approximating the Value of 7i 360 13.4.2 Problem 2: Finding Prime Numbers Less than 100 362 13.4.3 Problem 3: Analyzing an E-mail Address 366 13.5 Additional C Control Structures 3 6 8 13.5.1 The switch Statement 368 13.5.2 The break and continue Statements 370 13.5.3 An Example: Simple Calculator 370 13.6 Summary 372 Exercises 372 14 Functions 379 1 4 . 1 Introduction 3 7 9 14.2 Functions in C 3 8 0 14.2.1 A Function with a Parameter 380 14.2.2 Example: Area of a Ring 384 14.3 Implementing Functions in C 3 8 5 14.3.1 Run-Time Stack 385 14.3.2 Getting It All to Work 388 14.3.3 Tying It All Together 393 14.4 Problem Solving Using Functions 3 9 4 14.4.1 Problem 1: Case Conversion 395 14.4.2 Problem 2: Pythagorean Triples 397 14.5 Summary 3 9 8 Exercises 3 9 9 15 Testing and Debugging 407 1 5 . 1 Introduction 4 0 7 15.2 Types of Errors 4 0 8 15.2.1 Syntactic Errors 409
  • 14. Contents ix 15.2.2 Semantic Errors 409 15.2.3 Algorithmic Errors 411 15.3 Testing 412 15.3.1 Black-Box Testing 412 15.3.2 White-Box Testing 413 15.4 Debugging 414 15.4.1 Ad Hoc Techniques 414 15.4.2 Source-Level Debuggers 415 15.5 Programming for Correctness 417 15.5.1 Nailing Down the Specification 417 15.5.2 Modular Design 418 15.5.3 Defensive Programming 418 15.6 Summary 419 Exercises 4 2 1 16 Pointers and Arrays 427 16.1 Introduction 427 16.2 Pointers 428 16.2.1 Declaring Pointer Variables 429 16.2.2 Pointer Operators 430 16.2.3 Passing a Reference Using Pointers 432 16.2.4 Null Pointers 433 16.2.5 Demystifying the Syntax 434 16.2.6 An Example Problem Involving Pointers 434 16.3 Arrays 436 16.3.1 Declaring and Using Arrays 436 16.3.2 Examples Using Arrays 438 16.3.3 Arrays as Parameters 440 16.3.4 Strings in C 441 16.3.5 The Relationship Between Arrays and Pointers in C 446 16.3.6 Problem Solving: Insertion Sort 446 16.3.7 Common Pitfalls with Arrays in C 449 16.4 Summary 4 5 1 Exercises 4 5 1 17 Recursion 457 17.1 Introduction 457 17.2 What Is Recursion? 458 17.3 Recursion versus Iteration 459 17.4 Towers of Hanoi 460 17.5 Fibonacci Numbers 464 17.6 Binary Search 468 17.7 Integer to A S C I I 4 7 1 17.8 Summary 473 Exercises 473 18 I/O in C 481 18.1 Introduction 4 8 1 18.2 The C Standard Library 4 8 1 18.3 I/O, One Character at a Time 482 18.3.1 I/O Streams 482 18.3.2 p u t c h a r 483 18.3.3 g e t c h a r 483 18.3.4 Buffered I/O 483 18.4 Formatted I/O 485 18.4.1 p r i n t f 485 18.4.2 s c a n f 487 18.4.3 Variable Argument Lists 489 18.5 I/O from Files 4 9 1 18.6 Summary 493 Exercises 494 19 Data Structures 497 19.1 Introduction 497 19.2 Structures 498 19.2.1 typedef 500 19.2.2 Implementing Structures in C 501 19.3 Arrays of Structures 502 19.4 Dynamic Memory Allocation 504 19.4.1 Dynamically Sized Arrays 506 19.5 Linked Lists 508 19.5.1 An Example 510 19.6 Summary 516 Exercises 517 A The LC-3 ISA 521 A . l Overview 5 2 1 A.2 Notation 523 A.3 The Instruction Set 523 A.4 Interrupt and Exception Processing 543 A.4.1 Interrupts 543 A.4.2 Exceptions 544
  • 15. X Contents B From LC-3 to x86 547 B . l LC-3 Features and Corresponding x86 Features 548 B . l . l Instruction Set 548 B.l.2 Memory 553 B.l.3 Internal State 553 B.2 The Format and Specification of x86 Instructions 557 B.2.1 Prefix 558 B.2.2 Opcode 559 B.2.3 ModR/M Byte 559 B.2.4 SIB Byte 560 B.2.5 Displacement 560 B.2.6 Immediate 560 B.3 An Example 562 C The Microarchitecture of the LC-3 565 C . l Overview 565 C.2 The State Machine 567 C.3 The Data Path 569 C.4 The Control Structure 569 C.5 Memory-Mapped I/O 575 C.6 Interrupt and Exception Control 576 C.6.1 Initiating an Interrupt 579 C.6.2 Returning from an Interrupt, RTI 581 C.6.3 The Illegal Opcode Exception 582 C.7 Control Store 583 D The C Programming Language 585 D . l Overview 585 D.2 C Conventions 585 D.2.1 Source Files 585 D.2.2 Header Files 585 D.2.3 Comments 586 D.2.4 Literals 586 D.2.5 Formatting 588 D.2.6 Keywords 588 D.3 Types 589 D.3.1 Basic Data Types 589 D.3.2 Type Qualifiers 590 D.3.3 Storage Class 591 D.3.4 Derived Types 592 D.3.5 typedef 594 D.4 Declarations 595 D.4.1 Variable Declarations 595 D.4.2 Function Declarations 596 D.5 Operators 596 D.5.1 Assignment Operators 597 Arithmetic Operators 597 Bit-wise Operators 598 Logical Operators 598 Relational Operators 599 I ncrement/Decrement Operators 599 Conditional Expression 600 Pointer, Array, and Structure Operators 600 sizeof 601 Order of Evaluation 602 Type Conversions 602 Expressions and Statements 603 D.6.1 Expressions 603 Statements 604 604 I f 604 If-else 605 Switch 605 While 606 For 607 Do-while 607 Break 608 continue 608 return 609 D.8 The C Preprocessor 609 D.8.1 Macro substitution 609 D.8.2 File inclusion 610 D.9 Some Standard Library Functions 610 D.9.1 I/O Functions 611 D.9.2 String Functions 612 D.9.3 Math Functions 613 D.9.4 Utility Functions 613 D.6 D.7 D.5.2 D.5.3 D.5.4 D.5.5 D.5.6 D.5.7 D.5.8 D.5.9 D.5.10 D.5.11 D.6.2 Control D.7.1 D.7.2 D.7.3 D.7.4 D.7.5 D.7.6 D.7.7 D.7.8 D.7.9 E Useful Tables 615 E . l Commonly Used Numerical Prefixes E.2 Standard A S C I I codes 616 E.3 Powers of 2 617 F Solutions to Selected Exercises 619 615
  • 16. preface 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 how to make itbetter. 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 [lie 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. A majorproblem 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
  • 17. xii preface 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 program- ming language. Unlike the first edition, these chapters are more focused on the essential aspects of the language useful to a beginning programmer. Special- ized 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 program- ming. 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. Ashley Wise has written an LC-3 simulator that runs on UNIX. Both have incorporated interrupt-driven I/O into the simulator's function- ality. 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.
  • 18. preface xiii Alternate Uses of the Booh 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 one- semester 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.
  • 19. xhr preface 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 Col- lege; 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 believ- ers, 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 as wonderful. 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. Brian Fahs provided solutions to the exercises. 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.
  • 20. preface xv 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 exten- sive 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. f) 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
  • 21. preface to the first edition This textbook has evolved from EECS 100, the first computing course for com- puter science, computer engineering, and electrical engineering majors at the University of Michigan, that Kevin Compton and the first author introduced for the first time in the fall term, 1995. EECS 100 happened because Computer Science and Engineering 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 doing it, had its shortcomings. We decided that the reason students were not getting it was that they were forced to memorize technical details when they did not understand the basic underpinnings. The result is the bottom-up approach taken in this book. We treat (in order) MOS transistors (very briefly, long enough for students to grasp their global switch-level behavior), logic gates, latches, logic structures (MUX, Decoder, Adder, gated latches), finally culminating in an implementation of memory. From there, we move on to the Von Neumann model of execution, then a simple com- puter (the LC-2), machine language programming of the LC-2, assembly language programming of the LC-2, the high level language C, recursion, pointers, arrays, and finally some elementary data structures. We do not endorse today's popular information hiding approach when it comes to learning. Information hiding is a useful productivity enhancement tech- nique 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 contin- ually 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 problem (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.
  • 22. Htiaf Is in the Booh The book breaks down into two major segments, a) the underlying structure of a computer, as manifested in the LC-2; and b) programming in ahigh level language, in our case C. The LC-2 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-2. Chapter 3 takes the student from a MOS transistor, step by step, to a real memory. Our real memory consists of 4 words of 3 bits each, rather than 64 megabytes. The picture fits on a single page (Figure 3.20), making it easy for a student to grasp. By the time the students get there, they have been exposed to all the elements that make memory work. Chapter 4 introduces the Von Neumann execution model, as a lead-in to Chapter 5, the LC-2. The LC-2 is a 16-bit architecture that includes physical I/O via keyboard and monitor; TRAPs to the operating system for handling service calls; conditional 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 address- ing modes for loads and stores (direct, indirect, Base+offset, and an immediate mode for loading effective addresses). Chapter 6 is devoted to programming methodology (stepwise refinement) and debugging, and Chapter 7 is an introduction to assembly language programming. We have developed a simulator and an assembler for the LC-2. Actually, we have developed two simulators, one that runs on Windows platforms and one that runs on UNIX. The Windows simulator is available on the website and on the CD- ROM. Students who would rather use the UNIX version can download and install the software from the web at no charge. Students use the simulator to test and debug programs written in LC-2 machine language and in LC-2 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-2 machine language and assembly language programming assignments, which are essential for students to master the concepts presented throughout the first 10 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 Is. We go through the process of assembly step-by-step for a very simple LC-2 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 the
  • 23. xxii preface to the first edition 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 Rl, R2, R3 than with 0001001010000011. Chapter 8 deals with physical input (from a keyboard) and output (to a mon- itor). Chapter 9 deals with TRAPs to the operating system, and subroutine calls and returns. Students study the operating system routines (written in LC-2 code) for carrying out physical I/O invoked by the TRAP instruction. The first half of the book concludes with Chapter 10, a treatment of stacks and data conversion at the LC-2 level, and a comprehensive example that makes use of both. The example is the simulation of a calculator, which is implemented by a main program and 11 subroutines. The Language C From there, we move on to C. The C programming language occupies the second half of the book. By the time the student gets to C, he/she has an understanding of the layers below. 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 programming concepts are mastered, it is a short step for students to learn more advanced concepts such as objects and abstraction. Each time a new construct in C is introduced, the student is shown the LC-2 code that a compiler would produce. We cover the basic constructs of C (vari- ables, operators, control, and functions), pointers, recursion, arrays, structures, I/O, complex data structures, and dynamic allocation. 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-2 code is used to demonstrate how each C construct affects the machine at the lower levels. In Chapter 14, students are exposed to techniques for debugging high-level source code. Chapter 15 introduces functions in C. Students are not merely exposed to the syntax of functions. Rather they learn how functions are actually executed using a run-time stack. A number of examples are provided. Chapter 16 teaches recursion, using the student's newly gained knowledge of functions, activation records, and the run-time stack. Chapter 17 teaches pointers and arrays, relying heavily on the student's understanding of how memory is organized. Chapter 18 introduces the details of I/O functions in C, in particular,
  • 24. xxii preface to the first edition 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 concludes the coverage of C with structures, dynamic memory allocation, and linked lists. Along the way, we have tried to emphasize good programming style and coding 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 17) 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 16), he/she has already encountered all the underpinnings. Students understand how stacks work at the machine level (Chapter 10), and they under- stand the call/return mechanism from their LC-2 machine language programming experience, and the need for linkages between a called program and the return to the caller (Chapter 9). From this foundation, it is not a large step to explain func- tions by introducing run-time activation records (Chapter 15), 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. Horn to Use This Booh We have discovered over the past two years that there are many ways the material in this book can be presented in class effectively. We suggest six presentations below: 1. The Michigan model. First course, no formal prerequisites. Very intensive, this course covers the entire book. We have found that with talented, very highly motivated students, this works best. 2. Normal usage. First course, no prerequisites. This course is also intensive, although less so. It covers most of the book, leaving out Sections 10.3 and 10.4 of Chapter 10, Chapters 16 (recursion), 18 (the details of C I/O), and 19 (data structures). 3. 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. In this second course, the entire book is covered, spending the first two-thirds of the semester on the first 10 chapters, and the last one-third of the semester on the second half of the book. The second half of the book can move more quickly, given that it follows both Chapters 1-10 and the
  • 25. preface to the first edition xxi introductory programming course, which the student has already taken. Since students have experience with programming, lengthier programming projects can be assigned. This model allows students who were introduced to programming via an object-oriented language to pick up C, which they will certainly need if they plan to go on to advanced software courses such as operating systems. 4. Two quarters. 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 fcr Chapters 11-19. 5. Two semesters. Perhaps the optimal use of the book. A two-semester sequence for freshmen. No formal prerequisites. First semester, Chapters 1-10, with supplemental material from Appendix C, the Microarchitecture of the LC-2. Second semester, Chapters 11-19 with additional substantial programming projects so that the students can solidify the concepts they learn in lectures. 6. A sophomore course in computer hardware. Some universities have found the book useful for a sophomore level breadth-first survey of computer hardware. They wish to introduce students in one semester to number systems, digital logic, computer organization, machine language and assembly language programming, finishing up with the material on stacks, activation records, recursion, and linked lists. The idea is to tie the hardware knowledge the students have acquired in the first part of the course to some of the harder to understand concepts that they struggled with in their freshman programming course. We strongly believe the better paradigm is to study the material in this book before tackling an object-oriented language. Nonetheless, we have seen this approach used successfully, where the sophomore student gets to understand the concepts in this course, after struggling with them during the freshman year. Some Observations Understanding, Not Memorizing Since the course builds from the bottom up, we have found that less memorization of seemingly arbitary 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 understanding 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 component of the student's program, so the student
  • 26. Another Random Scribd Document with Unrelated Content
  • 30. THE HITTITE EMPIRE. 93 his shoulder ; facing them on the eastern wall are two reliefs of strange character. One of them depicts the youthful god, whose name perhaps was Attys, embracing with his left arm the eunuch-priest, above whose head is engraved the strange symbol that has been already described. The other represents a god's head crowned with the peaked tiara, and supported on a double-headed lion, which again stands on the hinder feet of two other lions, whose heads rest on a column or stem. All these sculptures were once covered with stucco, and thus preserved from the action of the weather. It is evident that in these two mountain recesses we have a sanctuary, the forms and symbols of whose deities were sculptured on its walls of living rock. It was a sanctuary too holy to be confined within the walls of the city, and the supreme deities to whom it was dedicated were a god and a goddess, served by a multitude of male and female priests. In fact, as Prof. Perrot remarks, Boghaz Keui must have been a sacred city like Komana, whose citizens were consecrated to the chief divinities adored by the Hittites, and were governed by a high-priest. It was as much a ' Kadesh ' or ' Hierapolis,' as much a ' holy city,' as Carchemish itself. It is not its sculptures only which prove to us that it was a city of the Hittites. The figures of the deities have attached to them, as at Eyuk, the same hieroglyphs as those which meet us in the inscriptions of Hamath and Aleppo, of Carchemish and Merash, and within its walls, southward of the ruins of its palace, Prof. Perrot discovered a long text of nine or ten lines cut out of the rock, and though worn and disfigured by time and weather, still showing the forms of many
  • 31. 94 THE HITTITES. Hittite characters. So far as can be judged from a photograph of it he has published, the forms are the same as those which are found on the Hittite monuments of Syria. Tedious as all these details may seem to be, it has been necessary to give them, since they tell us what was the appearance and construction of a Hittite city, a Hittite palace, and the interior of a Hittite temple. The discoveries recently made in the Hittite districts south of the Taurus, show us that here too the palaces and temples were like those of Eyuk and Boghaz Keui. Here too we find the same dados sculptured with the same figures dressed in the same costume ; here too we meet with the same lions, and the same winged deities standing on the backs of animals. A photograph of a piece of sculpture on a block of basalt at Carchemish, taken by Dr. Gwyther, might have been taken at Boghaz Keui. The art, the forms, and the symbolism are all the same. The high-road from Boghaz Keui to Merash must have passed through the defile of Ghurun, where Sir Charles Wilson discovered Hittite inscriptions carved upon the cliff. But there may have been a second road which led through Kaisariyeh, the modern capital of Kappadokia, southward to Bor or Tyana, where Prof. Ramsay found a Hittite text, and from thence to the silver mines of the Bulgar Dagh. The bas-reliefs of Ibreez are not far distant from the famous Cilician gates which led the traveller from the great central plateau of Asia Minor to Tarsus and the sea. It would seem that the silver mines of the Bulgar Dagh were first worked by Hittite miners. Silver had a special attraction for the Hittite race. The material
  • 32. THE HITTITE EMPIRE. 95 on which the Hittite version of the treaty between the Hittite king of Kadesh and the Egyptian Pharaoh was written was a tablet of that metal. That such tablets were in frequent use, results from the fact that nearly all the Hittite inscriptions known to us are not incised, but cut in relief upon the stone. It is therefore obvious that the Hittites must have first inscribed their hieroglyphs upon metal, rather than upon wood or stone or clay ; it is only in the case of metal that it is less laborious to hammer or cast in relief than to cut the metal with a graving tool, and nothing can prove more clearly how long accustomed the Hittite scribes must have been to doing so, than their imitation of this work in relief when they came to write upon stone. It is possible that most of the silver of which they made use came from the Bulgar Dagh. The Hittite inscription found near the old mines of these mountains by Mr. Davis, proves that they had once occupied the locality. It is even possible that their settlement for a time in Lydia was also connected with their passion for 'the bright metal.' At all events the Gumush Dagh, or ' Silver Mountains,' lie to the south of the Pass of Karabel, and traces of old workings can still be detected in them. However this may be, the Hittite monuments of Asia Minor confirm in a striking way the evidence of the Egyptian inscriptions. They show us that the Hittites worked for silver in the mountains which looked down upon the Cilician plain, from whence the influence of their art and writing extended into the plain itself. They further show that the central point of Hittite power was a square on either side of the Taurus range, which included Carchemish and Komagene in the south,
  • 33. g6 THE HITTITES. the district eastwards of the Halys on the north, and the country of which Malatiyeh was the capital in the east. The Hittite tribes, in fact, were mountaineers from the plateau of Kappadokia who had spread themselves out in all directions. A time came when, under the leadership of powerful princes, they marched along the two high-roads of Asia Minor and established their supremacy over the coast-tribes of the far west. The age to which this military empire belongs is indicated by the Egyptian character of the so-called image of Niobe on the cliff of Sipylos, as well as by the sphinxes which guarded the entrance to the palace of Eyuk. It goes back to the days when the rulers of Kadesh could summon to their aid the vassal-chieftains of the iEgean coast. The monuments the Hittites have left behind them in Asia Minor thus bear the same testimony as the records of Egypt. The people to whom Uriah, and it may be Bath-sheba, belonged, not only had contended on equal terms with one of the greatest of Egyptian kings ; they had carried their arms through the whole length of Asia Minor, they had set up satraps in the cities of Lydia, and had brought the civilisation of the East to the barbarous tribes of the distant West.
  • 34. CHAPTER V. THE HITTITE CITIES AND RACE. OF the history of the ' White Syrians ' or Hittites who lived in the land of Pteria, near the Halys, we know nothing at present beyond what we can gather from the ruins of their stronghold at Boghaz Keui and their palace at Eyuk. The same is the case with the Hittite tribes of Malatiyeh and Komag£ne When the inscription which adorns the body of a stone lion found at Merash can be deciphered, it will doubtless cast light on the early history of the city ; at present we do not know even its ancient name. It is not until we leave the mountainous region originally occupied by the Hittite race, and descend into the valleys of Syria, that the annals of their neighbours begin to tell us something about their fortunes and achievements. The history of their two southern capitals, Carchemish and Kadesh, broken and imperfect though it may be, is not an utter blank. The site of Carchemish had long been looked for in vain. At one time it was identified with the Kirkesion or Circesium of classical geography, built at the confluence of the Khabour and the Euphrates. But the Assyrian name of Kirkesion was Sirki, and its position did not agree with that assigned to ' Gargamis ' or Carchemish in the Assyrian texts. Professor Maspero subsequently placed the latter at Membij, the ancient Mabog or Hierapolis, on the strength of the evidence furnished by G
  • 35. 98 THE HITTITES. classical authors and the Egyptian monuments ; but the ruins of Membij contain nothing earlier than the Greek period, and their position on a rocky plateau at a distance from the Euphrates, is inconsistent with the fact known to us from the Assyrian inscriptions, that Carchemish commanded the fords over the Euphrates. To Mr. Skene, for many years the English consul at Aleppo, is due the credit of first discovering the true site of the old Hittite capital. On the western bank of the Euphrates, midway between Birejik and the mouth of the Sajur, rises an artificial mound of earth, under which ruins and sculptured blocks of stone had been found from time to time. It was known as Jerablus, or Kalaat Jerablus, ' the fortress of Jerablus,' sometimes wrongly written Jerabis ; and in the name of Jerablus Mr. Skene had no difficulty in recognising an Arab corruption of Hierapolis. In the Roman age the name of Hierapolis or ' Holy City ' had been transferred to its neighbour Membij, which inherited the traditions and religious fame of the older Carchemish ; but when the triumph of Christianity in Syria brought with it the fall of the great temple of Membij, the name disappeared from the later city, and was remembered only in connection with the ruins of the ancient Carchemish. Two years after Mr. Skene's discovery, Mr. George Smith visited Carchemish on his last ill-fated journey from which he never returned, and recognised at once that Mr. Skene's identification was right. The position of Jerablus suited the requirements of the Assyrian texts, it lay on the high-road which formerly led from east to west, and among its ruins was an inscription in Hittite characters. Not long afterwards there were brought to the British Museum the bronze bands which once adorned
  • 36. THE HITTITE CITIES AND RACE. 99 the gates of an Assyrian temple, and on one of these is a picture in relief of Carchemish as it looked in the days of Jehu of Israel. The Euphrates is represented as running past its walls, thus conclusively showing that Jerablus, and not Membij, must be the site on which it stood. The site was bought by Mr. Henderson, Mr. Skene's successor at Aleppo, and the money was invested by the former owner in the purchase of a cow. The mighty were fallen indeed, when the Hittite capital which had resisted the armies of Egypt and Assyria was judged to be worth no more than the price of a beast of the field. In 1878 Mr. Henderson was employed by the Trustees of the British Museum in excavating on the spot ; but no sufficient supervision was exercised over the workmen, and though a few remains of Hittite sculpture and writing found their way to London, much was left to be burned into lime by the natives or employed in the construction of a mill. The ancient city was defended on two sides by the Euphrates, and was exposed only on the north and west. Here, however, an artificial canal had been cut, on either side of which was a fortified wall. The mound which had first attracted Mr. Skene's attention marks the site of the royal palace, where the excavators found the remains of a dado like that of Eyuk, the face of the stones having been sculptured into the likeness of gods and men. The men were shod with boots with upturned ends, that unfailing characteristic of Hittite art. Carchemish enjoyed a long history. When first we hear of it in the Egyptian records it was already in Hittite hands. Thothmes III. fought beneath its walls, and his bravest warriors plunged into the Euphrates in G 2
  • 37. 100 THE HITTITES. their eagerness to capture the foe. Tiglath-pileser I. had seen its walls from the opposite shore of the Euphrates, but had not ventured to approach them. Assurnatsir-pal and his son Shalmaneser had received tribute from its king, and when it finally surrendered to the armies of Sargon it was made the seat of an Assyrian satrap. The trade which had flowed through it continued to pour wealth into the hands of its merchants, and the ' maneh of Carchemish ' remained a standard of value. When Egypt made her final struggle for supremacy in Asia, it was under the walls of Carchemish that the decisive struggle was fought. The battle of Carchemish in B.C. 604 drove Necho out of Syria and Palestine, and placed the destinies of the chosen people in the hands of the Babylonian king. It is possible that the ruin of Carchemish dates from the battle. However that may be, long before the beginning of the Christian era it had been supplanted by Mabog or Membij, and the great sanctuary which had made it a 1 holy city ' was transferred to its rival and successor. Like Carchemish, Kadesh on the Orontes, the most southern capital the Hittites possessed, was also a ' holy city.' Pictures of it have been preserved on the monuments of Ramses II. We gather from them that it stood on the shore of the Lake of Horns, still called the ' Lake of Kadesh/ at the point where the Orontes flowed out of the lake. The river was conducted round the city in a double channel, across which a wide bridge was thrown, the space between the two channels being apparently occupied by a wall. Kadesh must have been one of the last conquests made by the Hittites in Syria, and their retention of it was the visible sign of their supremacy over Western
  • 38. THE HITTITE CITIES AND RACE. lOI Asia. We do not know when they were forced to yield up its possession to others. As has been pointed out, the correct reading of 2 Sam. xxiv. 6 informs us that the northern limit of the kingdom of David was formed by ' the Hittites of Kadesh/ ! the entering in of Hamath,' as it seems to be called elsewhere. In the age of David, accordingly, Kadesh must still have been in their hands, but it had already ceased to be so when the Assyrian king Shalmaneser III. led his armies to the west. No allusion to the city and its inhabitants occurs in the Assyrian inscriptions, and we may conjecture that it had been destroyed by the Syrians of Damascus. As Membij took the place of Carchemish, so Emesa or Horns took the place of Kadesh. We have seen that the Hittites were a northern race. Their primitive home probably lay on the northern side of the Taurus. What they were like we can learn both from their own sculptures and from the Egyptian monuments, which agree most remarkably in the delineation of their features. The extraordinary resemblance between the Hittite faces drawn by the Egyptian artists and those depicted by themselves in their bas- reliefs and their hieroglyphs, is a convincing proof of the faithfulness of the Egyptian representations, as well as of the identity of the Hittites of the Egyptian inscriptions with the Hittites of Carchemish and Kappadokia. It must be confessed that they were not a handsome people. They were short and thick of limb, and the front part of their faces was pushed forward in a curious and somewhat repulsive way. The forehead retreated, the cheek-bones were high, the nostrils were large, the upper lip protrusive. They had, in fact, according to the craniologists, the characteristics of a Mongoloid race.
  • 39. 102 THE HITTITES. Like the Mongols, moreover, their skins were yellow and their eyes and hair were black. They arranged the hair in the form of a ' pig-tail,' which characterises them on their own and the Egyptian monuments quite as much as their snow- shoes with upturned toes. In Syria they doubtless mixed with the Semitic race, and the further south they advanced the more likely they were to become absorbed into the native population. The Hittites of Southern Judah have Semitic names, and probably spoke a Semitic language. Kadesh continued to bear to the last its Semitic title, and among the Hittite names which occur further north there are several which display a Semitic stamp. In the neighbourhood of Carchemish Hittites and Arameans were mingled together, and Pethor was at once a Hittite and an Aramean town. In short, the Hittites in Syria were like a conquering race everywhere ; they formed merely the governing and upper class, which became smaller and smaller the further removed they were from their original seats. Like the Normans in Sicily or the Etruscans in ancient Italy, they tended gradually to disappear or else to be absorbed into the subject race. It was only in their primitive homes that they survived in their original strength and purity, and though even in Kappadokia they lost their old languages, adopting in place of them first Aramaic, then Greek, and lastly Turkish, we may still observe their features and characteristics in the modern inhabitants of the Taurus range. Even in certain districts of Kappadokia their descendants may still be met with. ' The type,' says Sir Charles Wilson, ' which is not a beautiful one, is still found in some parts of Kappadokia, especially amongst the people living in the extraordinary subterranean
  • 40. THE HITTITE CITIES AND RACE. 103 towns which I discovered beneath the great plain northwest of Nigdeh.' The characteristics of race, when once acquired, seem almost indelible ; and it is possible that, when careful observations can be made, it will be found that the ancient Hittite race still survives, not only in Eastern Asia Minor, but even in the southern regions of Palestine.
  • 41. CHAPTER VI. HITTITE RELIGION AND ART. LUCIAN, or some other Greek writer who has usurped his name, has left us a minute account of the great temple of Mabog as it existed in the second century of the Christian era. Mabog, as we have seen, was the successor of Carchemish ; and there is little reason to doubt that the pagan temple of Mabog, with all the rites and ceremonies that were carried on in it, differed but little from the pagan temple of the older Carchemish. It stood, we are told, in the very centre of the ' Holy City.' It consisted of an outer court and an inner sanctuary, which again contained a Holy of Holies, entered only by the high- priest and those of his companions who were ' nearest the gods.' The temple was erected on an artificial mound or platform, more than twelve feet in height, and its walls and ceiling within were brilliant with gold. Its doors were also gilded, but the Holy of Holies or innermost shrine was not provided with doors, being separated from the rest of the building, it would seem, like the Holy of Holies in the Jewish temple, by a curtain or veil. On either side of the entrance was a cone-like column of great height, a symbol of the goddess of fertility, and in the outer court a large altar of brass. To the left of the latter was an image of ' Semiramis,' and not far off a great
  • 42. HITTITE RELIGION AND ART. 105 'sea' or Make,' containing sacred fish. Oxen, horses, eagles, bears, and lions were kept in the court, as being sacred to the deities worshipped within. On entering the temple the visitor saw on his left the throne of the Sun-god, but no image, since the Sun and Moon alone of the gods had no images dedicated to them. Beyond, however, were the statues of various divinities, among others the wonder-working image of a god who was believed to deliver oracles and prophecies. At times, it was said, the image moved of its own accord, and if not lifted up at once by the priests, began to perspire. When the priests took it in their hands, it led them from one part of the temple to the other, until the high-priest, standing before it, asked it questions, which it answered by driving its bearers forward. The central objects of worship, however, were the golden images of two deities, whom Lucian identifies with the Greek Hera and Zeus, another figure standing between them, on the head of which rested a golden dove. The gcddess, who blazed with precious stones, bore in her hand a sceptre and on her head that turreted or mural crown which distinguishes the goddesses of Boghaz Keui. Like them, moreover, she was supported on lions, while her consort was carried by bulls. In him we may recognise the god who at Boghaz Keui is advancing to meet the supreme Hittite goddess. In the Egyptian text of the treaty between Ramses and the king of Kadesh, the supreme Hittite god is called Sutekh, the goddess being Antarata, or perhaps Astarata. In later days, however, the goddess of Carchemish was known as Athar-'Ati, which the Greeks transformed into Atargatis and Derketo. Derketo was fabled to be the mother of Semiramis, in whom Greek
  • 43. 106 THE HITTITES. legend saw an Assyrian queen ; but Semiramis was really the goddess Istar, called Ashtoreth in Canaan, and Atthar or Athar by the Arameans, among whom Carchemish was built. Derketo was, therefore, but another form of Semiramis, or rather but another name under which the great Asiatic goddess was known. The dove was sacred to her, and this explains why an image of the dove was placed above the head of the third image in the divine triad of Mabog. The temple was served by a multitude of priests. More than 300 took part in the sacrifices on the day when Lucian saw it. The priests were dressed in v/hite, and wore the skull- cap which we find depicted on the Hittite monuments. The high- priest alone carried on his head the lofty tiara, which the sculptures indicate was a prerogative of gods and kings. Prominent among the priests were the Galli or eunuchs, who on the days of festival cut their arms and scourged themselves in honour of their deities. Such actions remind us of those priests of Baal who ( cut themselves after their manner with knives and lancets, till the blood gushed out upon them.' Twice a year a solemn procession took place to a small chasm in the rock under the temple, where, it was alleged, the waters of the deluge had been swallowed up, and water from the sea was poured into it. It is to this pit that Melito, a Christian writer of Syria, alludes when he says that the goddess Simi, the daughter of the supreme god Hadad, put an end to the attacks of a demon by filling with sea water the pit in which he lived. But in Lucian's time the demon was regarded as the deluge, and the account of the deluge given to the Greek writer agrees so closely with that which we read
  • 44. HITTITE RELIGION AND ART. 107 in Genesis as to make it clear that it had been borrowed by the priests of Hierapolis from the Hebrew Scriptures. It is probable, however, that the tradition itself was of much older standing, and had originally been imported from Babylonia. At all events the hero of the deluge was called Sisythes, a modification of the name of the Chaldaean Noah, while Major Conder found a place in the close neighbourhood of Kadesh which is known as ' the Ark of the Prophet Noah/ and close at hand a spring termed the Tannur or ' Oven,' out of which, according to Mohammedan belief, the waters of the flood gushed forth. But there were many other festivals at Mabog besides that which commemorated the subsidence of the deluge. Pilgrims flocked to it from all parts — Arabia, Palestine, Kappadokia, Babylonia, even India. They were required to drink water only, and to sleep on the ground. Numerous and rich were the offerings which they brought to the shrine, and once arrived there were called upon to offer sacrifices. Goats and sheep were the most common victims, though oxen were also offered. The only animal whose flesh was forbidden to be either sacrificed or eaten was the swine ; as among the Jews, it was regarded as unclean. After being dedicated in the court of the temple the animal was usually led to the house of the offerer, and there put to death ; sometimes, however, it was killed by being thrown from the entrance to the temple. Even children were sacrificed by their parents in this way, after first being tied up in skins and told that they were 'not children but oxen.' Different stories were current as to the foundation of the temple. There were some who affirmed that
  • 45. 108 THE HITTITES. Sisythes had built it after the deluge over the spot where the waters of the flood had been swallowed up by the earth. It is possible that this was the legend originally believed in Mabog before the traditions of Carchemish had been transferred to it. It seems to be closely connected with the local peculiarities of the site. The other legends had doubtless had their origin in the older Hierapolis. According to one of them, the temple had been founded by Semiramis in honour of her mother Derketo, half woman and half fish, to whom the fish in the neighbouring lake were sacred. Another account made Attys its founder, and the goddess to whom it was dedicated the divinity called Rhea by the Greeks. Derketo and Rhea, however, are but different names of the same deity, who was known as Kybele or Kybebe in Phrygia, and honoured with the title of 'the Great Mother.' Her images were covered with breasts, to symbolise that she was but mother-earth, from whom mankind derived their means of life. Her attributes were borrowed from those of the Babylonian Istar, the Ashtoreth of Canaan ; even the form assigned to her was that of the Babylonian Istar, as we learn from a bas-relief discovered at Carchemish, where she is represented as naked, a lofty tiara alone excepted, with the hands upon the breasts and a wing rising behind each shoulder. She was, in fact, a striking illustration of the influence exerted upon the Hittites, and through them upon the people of Asia Minor, by Babylonian religion and worship. Even in Lydia a stone has been found on which her image is carved in a rude style of art, but similar in form to the representations of her in the basrelief of Carchemish and the cylinders of ancient Chaldaea.
  • 46. HITTITE RELIGION AND ART. 109 This stone, like the seated figure on Mount Sipylos, is a witness that her cult was carried westward by the Hittite armies. Later tradition preserved a reminiscence of the fact. The Lydian hero Kayster was said to have gone to Syria, and there had Derketo for his bride, while on the other hand it was a Lydian, Mopsos, who was believed to have drowned the goddess Derketo in the sacred lake of Ashkelon. We have here, it may be, recollections of the days when Lydian soldiers marched against Egypt under the leadership of Hittite princes, and learnt to know the name and the character of Athar-'Ati, the goddess of Carchemish. The Babylonian Istar was accompanied by her son and bridegroom Tammuz, the youthful Sun-god, the story of whose untimely death made a deep impression on the popular mind. Even in Jerusalem Ezekiel saw the women weeping for the death of Tammuz within the precincts of the temple itself ; and for days together each year in the Phoenician cities the festival of his death and resurrection were observed with fanatic zeal. In Syria he was called Hadad, and identified with the god Rimmon, so that Zechariah (xii. 11) speaks of the mourning for Hadad-Rimmon in the valley of Megiddo. At Hierapolis and Aleppo also he was known as Hadad or Dadi, while throughout Asia Minor he was adored under the name of Attys, ' the shepherd of the bright stars/ The myth which told of his death underwent a slight change of form among the Hittites, and through them among the tribes of Asia Minor. He is doubtless the young god who on the rocks of Boghaz Keui appears behind the mother-goddess, riding like her on the back of a panther or lion. The people of Mabog did not forget that their temple
  • 47. IIO THE HITTITES. was but the successor of an older one, and that Carchemish had once been the ' Holy City' of Northern Syria. The legends, therefore, which referred to the foundation of the sanctuary were said to relate to one which had formerly existed, but had long since fallen into decay. The origin of the temple visited by Lucian was ascribed to a certain ' Stratonike, the wife of the Assyrian king.' But Stratonike is merely a Greek transformation of some Semitic epithet of 'Ashtoreth,' and marks the time when the Phoenician Ashtoreth took the place of the earlier Athar-'Ati. A strange legend was told of the youthful Kombabos, who was sent from Babylon to take part in the building of the shrine. Kombabos was but Tammuz under another name, just as Stratonike was Istar, and the legend is chiefly interesting as testifying to the religious influence once exercised by the Babylonians upon the Hittite people. Semiramis may turn out to have been the Hittite name of the goddess called Athar-'Ati by the Aramean inhabitants of Hierapolis. In this case the difficulty of accounting for the existence of the two names would have been solved in the old myths by making her the daughter of Derketo. But while Derketo was a fishgoddess, Semiramis was associated with the dove, like the Ashtoreth or Aphrodite who was worshipped in Cyprus. The symbol of the dove had been carried to the distant West at an early period. Among the objects found by Dr. Schliemann in the prehistoric tombs of Mykenae were figures in gold-leaf, two of which represented a naked goddess with the hands upon the breasts and doves above her, while the third has the form of a temple, on the two pinnacles of which are seated two doves. Considering how intimately the prehistoric art of My 
  • 48. HITTITE RELIGION AND ART. Ill kense seems to have been connected with that of Asia Minor, it is hardly too much to suppose that the symbol of the dove had made its way across the ^Egean through the help of the Hittites, and that in the pinnacled temple of Mykenae, with its two doves, we may see a picture of a Hittite temple in Lydia or Kappadokia. The legends reported by Lucian about the foundation of the temple of Mabog all agreed that it was dedicated to a goddess. The ' Holy City' was under the protection, not of a male but of a female divinity, which explains why it was that it was served by eunuch priests. If Attys or Hadad was worshipped there, it was in right of his mother ; the images of the other gods stood in the temple on sufferance only. The male deity whom the Greek author identified with Zeus must have been regarded as admitted by treaty or marriage to share in the honours paid to her. It must have been the same also at Boghaz Keui. Here, too, the most prominent figure in the divine procession is that of the Mother- goddess, who is followed by her son Attys, while the god, whose name may be read Tar or Tarku, 'the king,' and who is the Zeus of Lucian, advances to meet her. In Cilicia and Lydia this latter god seems to have been known as Sandan. He is called on coins the ' Baal of Tarsos,' and he carries in his hand a bunch of grapes and a stalk of corn. We may see his figure engraved on the rock of Ibreez. Here he wears on his head the pointed Hittite cap, ornamented with hornlike ribbons, besides the short tunic and boots with upturned ends. On his wrists are bracelets, and earrings hang from his ears. Sandan was identified with the Sun, and hence it
  • 49. 112 THE HITTITES. happened that when a Semitic language came to prevail in Cilicia he was transformed into a supreme Baal. The same transformation had taken place centuries before in the Hittite cities of Syria. Beside the Syrian goddess Kes, who is represented as standing upon a lion, like the great goddess of Carchemish, the Egyptian monuments tell us of Sutekh, who stands in the same relation to his Hittite worshippers as the Semitic Baal stood to the populations of Canaan. Sutekh was the supreme Hittite god, but at the same time he was localised in every city or state in which the Hittites lived. Thus there was a Sutekh of Carchemish and a Sutekh of Kadesh, just as there was a Baal of Tyre and a Baal of Tarsos. The forms under which he was worshipped were manifold, but everywhere it was the same Sutekh, the same national god. It would seem that the power of Sutekh began to wane after the age of Ramses, and that the goddess began to usurp the place once held by the god. It is possible that this was due to Babylonian and Assyrian influence. At any rate, whereas it is Sutekh who appears at the head of the Hittite states in the treaty with Ramses, in later days the chief cult of the ' Holy Cities' was paid to the Mother-goddess. His place was taken by the goddess at Carchemish as well as at Mabog, at Boghaz Keui as well as at Komana. In the Kappadokian Komana the goddess went under the name of Ma. She was served by 6000 priests and priestesses, the whole city being dedicated to her service. The place of the king was occupied by the Abakles or high-priest. We have seen that the sculptures of Boghaz Keui give us reason to believe that the same was also the case in Pteria; we know that it was so in
  • 50. HITTITE RELIGION AND ART. 113 other 'Holy Cities' of Asia Minor. At Pessinus in Phrygia, where lions and panthers stood beside the goddess, the whole city was given up to her worship, under the command of the chief Gallos or priest ; and on the shores of the Black Sea the Amazonian priestesses of Kybele, who danced in armour in her honour, were imagined by the Greeks to constitute the sole population of an entire country. At Ephesos, in spite of the Greek colony which had found its way there, the worship of the Mother-goddess continued to absorb the life of the inhabitants, so that it still could be described in the time of St. Paul as a city which was 'a worshipper of the great goddess.' Here, as at Pessinus, she was worshipped under the form of a meteoric stone 'which had fallen from heaven.' We may regard these ' Holy Cities,' placed under the protection of a goddess and wholly devoted to her worship, as peculiarly characteristic of the Hittite race. Their two southern capitals, Kadesh and Carchemish, were cities of this kind, and their stronghold at Boghaz Keui was presumably also a consecrated place. Their progress through Asia Minor was characterised by the rise of priestly cities and the growth of a class of armed priestesses. Komana in Kappadokia, and Ephesos on the shores of the yEgean, are typical examples of such holy towns. The entire population ministered to the divinity to whom the city was dedicated, the sanctuary of the deity stood in its centre, and the chief authority was wielded by a high-priest. If a king existed by the side of the priest, he came in course of time to fill a merely subordinate position. These 'Holy Cities' were also ' Asyla' or Cities of Refuge. The homicide could escape to them, and be H
  • 51. 114 THE HITTITES. safe from his pursuers. Once within the precincts of the city and the protection of its deity, he could not be injured or slain. But it was not only the man who had slain another by accident who could thus claim an ' asylum' from his enemies. The debtor and the political refugee were equally safe. Doubtless the right of asylum was frequently abused, and real criminals took advantage of regulations which were intended to protect the unfortunate in an age of lawlessness and revenge. But the institution on the whole worked well, and, while it strengthened the power of the priesthood, it curbed injustice and restrained violence. Now the institution of Cities of Refuge did not exist only in Asia Minor and in the region occupied by the Hittites. It existed also in Palestine, and it seems not unlikely that it was adopted by the great Hebrew lawgiver, acting under divine guidance, from the older population of the country. The Hebrew cities of refuge were six in number. Gne of them was ' Kedesh in Galilee,' whose very name declares it to have been a ' Holy City,' like Kadesh on the Orontes, while another was the ancient sanctuary of Hebron, once occupied by Hittites and Amorites. Shechem, the third city of refuge on the western side of the Jordan, had been taken by Jacob ' out of the hand of the Amorite' (Gen. xlviii. 22) ; and the other three cities were all on the eastern side of the Jordan, in the region so long held by Amorite tribes. We are therefore tempted to ask whether these cities had not already been 'asyla' or cities of refuge long before Moses was enjoined by God to make them such for the Israelitish conquerors of Palestine. Closely connected with Hittite religion was Hittite art. Religion and art have been often intertwined to 
  • 52. Welcome to our website – the ideal destination for book lovers and knowledge seekers. With a mission to inspire endlessly, we offer a vast collection of books, ranging from classic literary works to specialized publications, self-development books, and children's literature. Each book is a new journey of discovery, expanding knowledge and enriching the soul of the reade Our website is not just a platform for buying books, but a bridge connecting readers to the timeless values of culture and wisdom. With an elegant, user-friendly interface and an intelligent search system, we are committed to providing a quick and convenient shopping experience. Additionally, our special promotions and home delivery services ensure that you save time and fully enjoy the joy of reading. Let us accompany you on the journey of exploring knowledge and personal growth! ebookfinal.com