The Second Book Of Machine Language

by Richard Mansfield
This book shows how to put together a large machine language program. All of the fundamentals were covered in my first book, Machine Language for Beginners. What remains is to put the rules to use by constructing a working program, to take the theory into the field and show how machine language is done.
Showing how to construct an assembler-written entirely in machine language would serve two useful purposes. It would illustrate advanced programming technique and also provide the reader with a powerful assembler to use in other ML programming.
This book, then, offers the reader both a detailed description of a sophisticated machine language program (the LADS assembler) and an efficient tool, a complete language with which to write other machine language programs. Every line in the LADS assembler program is described. All the subroutines are picked apart and explained. Each major routine is examined in depth.
LADS, the Label Assembler Development System, is a fast, feature-laden assembler-it compares favorably with the best assemblers available commercially. And not the least of its virtues is the fact that few programs you will ever use will be as thoroughly documented and therefore as accessible to your understanding, modification, and customization.
LADS is a learning device too. By exploring the assembler, you will learn how to go about writing your own large machine language (ML) programs. You will see how a data base is created and maintained, how to communicate with peripherals, and how to accomplish many other ML tasks. Also, because you can study the creation of a computer language, the LADS assembler, you will gain an in-depth knowledge of the intimate details of direct communication with your computer.
Most programming involves a tradeoff between three possible objectives: speed, brevity, or clarity. You can program with the goal of creating the fastest running program possible. Or you can try to write a program which uses up as little memory as possible. Or you can try to make the program as understandable as possible, maximizing the readability of the program listing with REMarks.
LADS emphasizes clarity so that its source code will serve as a learning tool and as the focus of this book. It's designed so that important events in the program can be easily explained and understood. Virtually every ML instruction, every tiny step, is commented within the source code listings following each chapter.
This doesn't mean that LADS is flabby or slow. Assembling roughly 1000 bytes a minute and taking up 5K in memory, LADS is considerably faster and more compact than most commercial assemblers. That's because, in ML, you can have the best of both worlds: You can comment as heavily as you want, but the assembler will strip off the comments when it creates the object code. In this way, clarity does not sacrifice memory or speed.
The frequent comments contribute considerably to the educational value of this assembler. Exploring LADS is a way to learn how to achieve many common programming goals and how to construct a large, significant program entirely in ML. An additional advantage of this comprehensibility is that you'll be able to modify LADS to suit yourself: Add your own pseudo-ops, define defaults, format output. All this is referred to as a language's extensibility. We'll get to this in a minute.
What BASIC is to BASIC programming, an assembler is to ML programming. LADS is a complete language. You write programs (source code) which LADS translates into the finished, executable ML (object code). Unlike less advanced assemblers, however, symbolic assemblers such as LADS can be as easy to use as higher level languages like BASIC. The source code is very simple to modify. Variables and subroutines have names. The program can be internally commented with REM-like explanations. Strings are automatic via the BYTE command. There are a variety of other built-in features, the pseudo-ops, which make it easy to save object programs, control the screen and printer listings, choose hex or decimal disassembly, and service other common programming needs.
Perhaps the best feature of LADS, though, is its extensibility. Because you have the entire source code along with detailed explanations of all the routines, you can customize LADS to suit yourself. Add as many pseudo-ops as you want. Redesign your ML programming language anytime and for any reason. Using an extensible programming language gives you control not only over the programs you design, but also over the way that they are created. You can adjust your tools to fit your own work style.
Do you often need to subtract hex numbers during assembly? It's easy to stick in a - command. Would you rather that LADS read source programs from RAM memory instead of disk files? (This makes it possible to assemble using a tape drive. It can also be a bit faster.) In Chapter 11 we'll go through the steps necessary to make this and other modifications. You'll be surprised at how easy it is.
Finally, studying the language (the LADS assembler) which produces machine language will significantly deepen your understanding of ML programming.
Read More/Download

Popular Posts