Previous | Contents | Next

An Introduction

This book is designed for those people who have a reasonable understanding of BASIC, but whose knowledge of machine code is zero. Starting at first principles with BASIC programs, we gradually introduce the concept of a machine code subroutines, and develop this theory throughout the book. Before long you'll find your understanding of machine language increasing, and you'll soon begin writing your own routines and programs.

Machine language is no more than a second computer language - very much like BASIC is in fact. We start by learning the simplest of instructions, and become familiar with them by using them in BASIC programs. An example would be a SCROLL program given in chapter four, which moves the screen downward instead of upward. This effect is rather interesting, and certainly surprising.

Printing strings is the next thing covered, and this involves making use of the PRINT subroutine in the ROM. The routine is demonstrated by printing a draughts board which later on in the book we shall make use of.

We explain the machine code equivalent of the INKEY$ function, and use the technique of scanning the keyboard to write a typewriter-type program which uses greatly enlarged versions of the keyboard characters.

The same keyboard scanning technique is used to make musical notes in [a] rather surprising manner. Two whole octaves can be produced from your machine, enabling you to play a wide variety of tunes at the touch of the keyboard.

The computer is made to generate many intricate and fascinating displays in the program LIFE. It challenges the skill of an unwary human operator in graphics games such as SPIRAL. A draughts program is included, with several interesting features. This is actually a teaching game because you are encouraged to add your own features to it as you progress.

Careful study of the listings of these programs will teach you a great deal about machine code, but of course the biggest steps in learning will come from experiment. By writing your own programs, or by adapting mine - by all means do - they are intended for this purpose, and some in fact are deliberately improvable for this reason.

To make the best use of this book you are advised to work through from start to finish, and where asked to alter or improve programs you should make an attempt to do so. It's not difficult, since the book progresses very slowly, but will require some thought.

The last two chapters in the book are rather ambitious. An algorithm by which the ROM may be disassembled is given, but only guidelines are given as to how you may write a program for it. All of the arithmetic subroutines are explained in detail, even NEW ROM floating point functions like SIN and COS, and how the numbers are stored.

The heavily tabulated appendices at the back are designed to be used as a source of reference throughout the book. Any piece of information you need to know can generally be found in these appendices, or in chapter eight, which is a kind of "catalogue" of machine code.

The first chapter begins on the next page, and starts with an introduction to the use of "hexadecimal"....

Previous | Contents | Next