Classic Computer Magazine Archive COMPUTE II ISSUE 2 / JUNE/JULY 1980

Programming & Interfacing the 6502, with Experiments

by Marvin L. Dejong

Howard W. Sams & Co., Inc.
4300 West 62nd St.
Indianapolis, IN 46268
414 pages, $13.95

Review by Jim Butterfield

This book might have been subtitled, “A hands-on guide to the 6502.” That's what it really is: it invites the owner of a KIM, SYM or AIM to learn the 6502 by working through example after example on his machine. Most of us learn by doing, rather than just by reading; and this book contains eighty carefully graded “experiments” that encourage you to get your hands on the machine and prove to yourself that it works the way the book says.

This is good stuff: the text and experiments are carefully graded and go at a gentle pace. You won't get very many advanced programming concepts here: the book covers only the basics. But it does a careful and thorough job. Early concepts are developed with care at a pace the beginner can cope with.

As the title suggests, the book comes in two parts. Part I deals with programming the 6502, Part II with interfacing. Each chapter begins with a statement of objectives, identifying what you may expect to learn there. Each chapter ends with a series of experiments designed to reinforce what you have learned. An experiment often takes the form: “load this program… now do this… what do you see? …can you explain why?” Emphasis is on gaining understanding as to how a simple program operates; the last experiment or two in a chapter often suggest small projects for the reader.

Machine language is developed a few op-codes at a time. Loads, Stores, and Transfers are introduced first, and subsequent chapters progressively bring in more commands. Branches, for example, don't arrive until chapter six – I would rather have seen them a little earlier because I believe loops are so important – and the op codes aren't completely covered until chapter 9 has been completed. Advanced addressing modes, such as indexing and indirect addressing, are held back until chapter 8. It's all carefully graded, and the going is about as easy as it can be for machine language.

The pace changes in Part II, Interfacing the 6502. We're thrown quite abruptly into the hardware field: logic diagrams, truth tables, timing charts and oscilloscope traces start to appear with great rapidity. The author seems to assume that the reader will have some understanding of hardware, which is likely true for a sizable fraction of KIM/SYM/AIM owners. A beginner who isn't sure about the different shapes of AND and NOR logic symbols will have to work hard.

In keeping with the accelerated pace of the material, Part II takes on a number of more ambitious projects, some of which might prove to be of special interest to readers. Music synthesis, an ASCII input port, data logging, a morse keyer, and a lunar occultation program are included; most are adapted from other sources but are accompanied by extra explanations.

The book contains a quite extensive appendix section, with emphasis on hardware. Many of the data sheets are printed in very fine type and may be hard to read. An index is included.

Is it possible to write a book which deals with three different machines — the KIM, SYM, and AIM? The experiments jump around from one machine to the other without always specifying which machine is intended. Even so, most users will be able to sort it out without too much trouble. Two key tables point out vital addresses on the respective machines; readers may find themselves repeatedly scrambling for page 44 or 55 – I wish that these had been printed on fold-out sheets so that they could be visible during the experiments.

The author deals carefully with difficult subjects; he doesn't gloss over the tricky parts but treats them with precision. One thing, however, bothers me: his notation for immediate-mode addressing. If you want to load the A register with the value 12 decimal, any of the following may be used on most assemblers:

LDA #12
LDA #$0C
LDA #%00001100

"…you may code the number in binary, decimal, hexadecimal or whatever, but you must include that pounds sign (#) to indicate Immediate mode." The author codes LDA $0C ; most assemblers would take this to mean, “load the contents of address 12” – not the value 12. Readers will have to re-adapt when they start using an assembler.

The book is a good, gentle introduction to programming the 6502. It's a little harder going for interfacing, especially for hardware beginners.

The “hands-on” nature of the experiments tend to drive the lessons home. It's a good way to come to grips with your computer.