
ASSEMBLY LANGUAGE - WEEK IX				December 28, 1986


THE GUESS NUMBER GAME


Well, we have built a series of subroutines, assembled them, and proved they worked by testing them. Now, following our outline from Lesson VI, we can put these parts together and come out with the GUESS NUMBER game. It should work the first time; all the parts worked before. 

The procedure for building any other machine language program would involve the same steps we went through for the GUESS NUMBER game:

1. We would have to define the problem (program) and the steps necessary to solve the problem.

2. Each step would have to be broken down into smaller steps until we could define the step as an assembly language routine.

3. Each assembly language routine could be written and debugged individually.

4. The assembly language routines would then be combined to define the steps.

5. The body of the program is written to call the routines in the proper order.


There really is a lot of thought that goes into the creation of the program (solution to the problem) before any code is written. The more time that is spent before you start writing code can save time later. If you are sure that you have all alternatives to a decision defined, or all possible answers to a question considered, you can save yourself some "Ooop, I didn't think of that" problems later. Assembly language programming is less forgiving than other languages in allowing for afterthoughts. 

Assembly language forces you to keep track of all the  variables and all the intermediate numbers. You have to plan where you are going to store those variables, numbers and messages. If you don't intend on keeping a number, you must make sure you don't need it again. The computer has limited capabilities for calculations and decisions, so you have to do all the preliminary thought ahead of time. 

We must not lose sight of the fact that the computer is only a set of switches, and all programs start off by setting or changing these switches. Someone, at some time, wrote the code to allow us to get from the language of switches to a series of words or symbols that we understand.

This introduction to assembly language was intended to give you a set of basic tools. With this set of tools, you can write simple programs. There are over 690 mnemonic statements you can make to the Z-80 microprocessor. We have not covered all that vocabulary. Rather, we started with a few simple commands and built a set of simple, but necessary routines. You should now be able to look at an assembly language program in a magazine article and follow the programmer's logic. Programming is a language, and must be learned like any other language, by practice. We start with what we know, and gradually build on that foundation. This is, really, only the beginning.
. . ... ...-.... 1200  N81N          ........................ . ... ...-.... 1200  N81N          ....                                                                                                                                