Preface to Introduction to RISC Assembly Language Programming

This book is based on a one semester introductory computer architecture course for first year computing students in the School of Computer Applications, Dublin City University using SPIM, a virtual machine that runs programs for the MIPS R2000/R3000 computers. The architecture of the MIPS is an ideal example of a simple, clean RISC (Reduced Instruction Set Computer) machine, which makes it easy to learn and understand. The processor contains thirty two general-purpose registers and a well-designed instruction set. The existence of a simulator for the processor greatly simplifies the development and debugging of assembly language programs. For these reasons, MIPS is the preferred choice for teaching computer architecture in the 2000s, just as the Motorola 68000 was during the 1980s.

The material assumes the reader has never studied computer programming before, and is usually given at the same time as a programming course in a high level language like Java or C. The main data structures covered are strings, arrays and stacks. The ideas of program loops, if statements, procedure calls and some recursion are presented. The philosophy behind the book is to speed up the learning process relative to other MIPS architecture books by enabling the reader to start writing simple assembly language programs early, without getting involved in laborious descriptions of the trade-offs involved in the design of the processor. The most successful approach to computer architecture is to begin by writing numerous small assembly language programs, before going on to study the underlying concepts. Thus this text does not address topics such as logic design or boolean algebra, but does contain example programs using the MIPS logical instructions. While processors like the MIPS were designed for high level language compilation and as such are targeted at compilers rather than human programmers, the only way to gain an appreciation of their functionality is write many programs for the processor in assembly language.

The book is associated with automatic program testing system MIPSMARK which allows a lecturer to set assembly language programming questions and collect and mark the assignments automatically, or a reader to test a MIPS assembly language program against several different cases and determine if it works, as described in Appendix A. The exam system is written as a collection on Unix C shell scripts. If the instructor or student does not wish to adopt this learning approach, the text book can be used in a traditional manner. A student who can write an assembly language program which converts a number to an ASCII string in hexadecimal format under exam conditions has demonstrated a thorough understanding of all the principles of introductory computer architecture. There is little point in describing concepts such as pipelining, delayed branches of advanced compiler topics to students who are not yet familiar with simple program loops.

Assembly language programming is usually considered an arcane and complex discipline. This view arises among those whose first experience of assembly language programming was the instructions and registers of architectures like the Intel 8086 family. Programming in a RISC architecture is very different due to the elegant, compact and simple instruction set. Students of this text who have never programmed before and begin to study it simultaneously with a course on C programming report it is easier and more logical to program in assembly! In addition, because of the programming exam system, there is a higher pass rate and level of proficiency achieved by students on the assembly course than on the more traditional C course.

The SPIM simulator is available in the public domain. Overhead projector slides of lecture notes, all example programs and all exam questions are available from Introduction to RISC Assembly Language Programming. The programs that correct the questions, together with test cases and solutions are available to lecturers adopting the course.

The SPIM simulator software was designed and written by James R. Laurus laurus@cs.wisc.edu. This book was partly inspired by John Conry's course at the University of Oregon which he has made available on the Internet. I would like to thank him for permission to use some of his material. Thanks to Dr. David Sinclair for reading an early draft and providing many important suggestions. Also thanks to Karen Sutherland and Keith Mansfield at Addison Wesley Longman.

Return to Introduction to RISC Assembly Language Programming