This book has been designed and used as a text for a second course in computer programming. It has developed from class notes for a course offered at the University of Texas at Austin to undergraduate students. These students have had one previous programming course and should know, from that first course, the basic operation of computers, in general, and have some basic skills in converting problem statements into programs in a higher level language, such as Fortran. The second course, and this text, assumes that the student knows how to program, i.e., how to find an algorithm to solve a problem and convert that algorithm into a program.
The purpose of this book is to teach the student about lower level computer programming: machine language and assembly language, and how these languages are used in the typical computer system. This is meant to give the student a basic understanding of the fundamental concepts of the organization and operation of a computer. Even if the student never again programs in assembly language (and we would hope that they never have to!) it is important that they understand what the computer is doing at the machine language level. A good understanding of computer organization translates into a better understanding of the features and limitations of all computer facilities, since all systems must eventually rest on the underlying hardware machine.
The content of this text follows the recommendations of the ACM Curriculum 68 for Course B2 "Computers and Programming." After a brief review of the general concepts of computers in Chapter 1, the remainder of the text uses the MIX computer to provide an example machine for illustrating computer organization and programming. Chapter 2 and Chapter 3 present the architecture of the MIX computer, its machine language and the MIXAL assembly language. Programming techniques in assembly language are covered in Chapters 4 and 5 with Chapter 5 concentrating mostly on input/output programming. The use and implementation of the subroutine concept is investigated in Chapter 6.
Systems programs are considered in the next three chapters. Chapter 7 explores loaders, while Chapter 8 discusses assemblers. In Chapter 7 the code for a simple, but real, absolute loader is given; in Chapter 8, the code for a MIXAL assembler is given. These two programs provide an opportunity for the student to see and study a real loader and assembler, and not simply the concepts in the abstract. Chapter 9 briefly discusses other system programs, macro assemblers, compilers, interpreters, and operating systems.
From these chapters, the basic concepts of assembly language programming and programs should be evident to the student. Chapter 10 then proceeds to present a brief description of several other computers, to introduce the student to both the similarities and differences among computer systems.
In our one-semester course, these concepts are reinforced by numerous programming assignments. The early assignments emphasize basic programming techniques such as simple arithmetic, input/output, character manipulation and array handling. The later assignments have included writing either a relocatable loader and two-pass assembler for a subset of the MIX computer, or writing an interpreter and one-pass load-and-go assembler for a simple minicomputer (16 instructions, four general registers, etc.). All of these assignments are programmed in MIXAL. The last assignment is to write a simple program in the new assembly language of their own assembler. Thus, students should see that they know how to program in assembly language, in general, and not simply in MIXAL.
The major question in your mind now is undoubtedly: Why MIX? MIX is a pseudo computer, not a real one. This is at once both its major drawback and its major advantage. The major drawback to MIX is, of course, that it is not real; this implies that the use and programming of the MIX computer will include a certain air of artificiality which may annoy and confuse some students.
However, from an educational point of view, MIX is ideal. It is simple, easy to understand, and yet typical of many computers. Machine and assembly languages are different for each computer. However, the techniques of assembly language programming are largely machine independent. Thus, learning one assembly language provides the basis for quickly and easily learning any other assembly language. This is emphasized by the descriptions of other computers in Chapter 10.
Also consider the alternative to teaching MIX: teaching the structure and language of a real computer. As Knuth has written, in the Preface to Volume 1 of The Art of Computer Programming (Addison-Wesley, Reading, Mass., 1973),
"Given the decision to use a machine-oriented language, which language should be used? I could have chosen the language of a particular machine X, but then those people who do not possess machine X would think this book is only for X-people. Furthermore, machine X probably has a lot of idiosyncrasies which are completely irrelevant to the material in this book, yet which must be explained; and in two years the manufacturer of machine X will put out machine X + 1 or machine 10X, and machine X will no longer be of interest to anyone".
Knuth continues that it is very unlikely that programmers will only use one computer in their life. Each new machine can be easily learned once the first machine is understood, but the ability to change smoothly from one computer to another is an important skill for a programmer. Thus, teaching first MIX and then another, real, computer is preferable, since it immediately forces the student to understand how to move from machine to machine. In my own, so far short career, I have programmed on several different computers (IBM 1620, CDC 3600, CDC 6500, PDP-11/20, HP 2116, CDC 1700, IBM 360/370, DEC-10, SDS Sigma 5, Nova 3/D).
From an economic viewpoint also, the MIX machine is an advantage over a real computer. It is often said that a simulated machine is much more expensive than a real machine, and for production computation this is undeniably true. However, for a student environment, most of the computer time is in assembly and debugging, not execution. The simple MIXAL assembler, written as a cross assembler for the machine at hand, generating load-and-go code for a simulator with good trace, dump, and error detection facilities will provide a much better instructional tool at a lower price than most real assemblers with their extensive pseudo instructions, macros, relocatable code, and operating system input/output, most of which cannot and need not be used in an introductory course.
The construction of a MIXAL assembler/simulator is, although nontrivial, within the range of a senior year or early graduate student project. The complexities are derived mainly from the need for an event driven simulator to allow CPU and I/O overlap, and the need to provide the best possible debugging facilities. Properly written, the design and code for these systems would be easily transported over the years to new computer systems.
One further benefit from the use of MIX is the ability to easily pick up and use The Art of Computer Programming books by D. E. Knuth. These are very handy in later courses as references and texts. More can be learned from them with a good knowledge of MIX.
In summary, we feel that MIX is preferable to any real machine for teaching a beginning course in machine language, assembly language and computer organization. The major problem we have faced in using MIX has been the lack of an adequate text, a problem which we hope has now been solved.
I would especially like to express my gratitude to the reviewers -- Stan Benton, Montclair State College; Michel Boillot, Pensacola Junior College; Werner Rheinboldt, University of Maryland; and Robert C. Uzgalis, University of California, Los Angeles -- whose comments and suggestions helped greatly in guiding the manuscript to its final form.
James Peterson Austin, Texas August 11, 1977