"The PC Assembler Tutor"
Total Page:16
File Type:pdf, Size:1020Kb
1 Hi! Welcome to "The PC Assembler Helper" and "The PC Assembler Tutor". Both the program and the tutorial are designed to help those who are just starting to learn assembler language as well as those who know some assembler instructions but want to have a firmer grasp of the complete instruction set for the 8086. There are two significant problems to learning assembler language. First, it is difficult to do either input or output at the assembler level. Imagine trying to learn BASIC if you were not allowed the following two instructions: PRINT RESULT INPUT NEW.DATA Without PRINT and INPUT, you might be able to write a program but you would not be able to see the results. You would never be sure that the results were what you wanted. Also, you would not be able to vary the data. It would have to be coded into the program. "The PC Assembler Helper" has taken care of this problem. It provides input and output of all standard 8086/8087 integral data types. These include 1 byte, 2 byte, 4 byte and 8 byte signed and unsigned numbers along with 1 byte and 2 byte hex, ASCII and binary data. Lastly, there is i/o for 10 byte BCD numbers. The interface has been designed so that beginners can use it with a minimum of trouble. The second major problem is that most assembler books regard the 8086 as a black box. There is no way of seeing the workings of the chip itself. What exactly happens when you add two numbers? What about multiplication? Once again, "The PC Assembler Helper" has come up with the solution. It allows you to view all the registers and flags at will. These registers can be independently formatted. If one register holds ASCII data while another has binary information and yet a third has a signed number, then each register can be set to display the appropriate type of data. This, you will find, is invaluable. A third, though less important problem, is assembler overhead. There is a certain structure that must be followed to get the program to assemble and run correctly. This has been provided in template files. All you need to do is copy the appropriate template file and put the code in a predefined location to get your program to run correctly. For simple programs this can cut your work in half. It also minimizes the number of typos. "The PC Assembler Tutor" is built around the Helper. It systematically goes through the 8086 instruction set, having you write small programs to illustrate how each instruction works. At ______________________ The PC Assembler Tutor - Copyright (C) 1989 Chuck Nelson The PC Assembler Tutor 2 ______________________ the end you should have a feeling for all the instructions except a few which involve the 8087 or peripheral hardware. These will be mentioned, but not used. You will be a better programmer if you know how all the instructions work. There are times when one specific instruction is just what you want. If you don't know that it exists or how it works, you won't use it. This way, if you run across a situation where you think that a certain instruction might be useful to you, you can go back to the Tutor to refresh your memory and be able to put the instruction to use almost immediately. If you are a beginner, I feel confident that you will learn faster and more thoroughly than with any other method. If you know some assembler but would like to know more, I'm sure that there is lots that would interest you. AAD SBB XLAT REPNE SCAS Do you know what these are? What about segment overrides? Do you know when to use them and when to avoid them? Do you know ALL the allowable addressing modes? What actually is an ASSUME statement? In order to let you see if you find the material interesting, you may go through chapters 0 - 4 chapters without any obligation. You may also make an archival copy of the disks (you are urged to do so). If you continue after the fourth chapter then please register by sending $9.95 (or $10.60 for Californians) to Nelsoft. The registration form is at the end of this introduction. If I followed the pricing structure of other people I would be charging several times as much. My goal is different. I want everyone who can benefit from the program and tutorial to use them, and I want everyone who uses them to do so legally. Therefore, I have priced them so that everyone can pay for them without any inconvenience. If you use them, you can certainly afford my minimal price. The material is sequential. Chapter 0 should be read before starting on the other chapters and the chapters should be read in order. Appendix 1 contains all the subroutine calls in "The Assembler Helper" and how to access them. Appendix 2 is an alphabetical list of all the 8086 instructions, telling what they do and showing all allowable syntaxes. Appendix 3 gives the speed of all instructions along with a list of which flags are affected (you will learn what this means in the Tutor). It is to your benefit to start at the beginning and work your way through. Chapter 0 contains material that you need to know, so you must read it. The text has been broken up into sections so that no printout is longer than 10 pages or so. All text files have a file extension .DOC. If a chapter is much longer than Introduction 3 ____________ that, it will be divided into parts, indicated by -1, -2, -3 after the chapter number. These files should be printable with the DOS 'print' command. The only imbedded printer command code is form feed for the next page. The text runs about 2500 characters a page, so you can estimate the size of the printout from the size of the text file. Curly brackets in the text denote a footnote.{1} Some of the footnotes are technical and will be understood by only a quarter of the people. If you are one of that quarter, fine. If not, the important thing is not that you understand the outline of the proof, but that you believe that what is being proved is true. The assembler level is for those who have some degree of intellegence. You have an unparalleled opportunity to screw things up at this level. If you got Cs and Ds in high school algebra because you didn't quite understand what was going on, then you probably shouldn't do assembler programming.{2} In addition, I assume that you have done a lot of programming, preferably in either Pascal or C. BASIC is a nice language, but it is missing a certain type of structure which is vital for creating robust code in assembler language. If BASIC is all you know, I would recommend that you learn C first and then come back to assembler. You will be a better programmer for it.{3} Finally, "The Assembler Helper" assumes that it has control of the screen. If you are hooked up to a debugger, there may be a conflict. There is a subroutine in the Helper called "set_timer" which may help minimize this conflict. You need to be in chapter 5 or so before you will be able to use it. See \APPENDIX\APP1.DOC for details. If you are ready to go, please look at the following two pages and then read INTRO2.DOC. It will explain a little about what an assembler is. I hope you enjoy using the Helper and the Tutor as much as I enjoyed writing them. Chuck Nelson ____________________ 1. Like this one. 2. If you got Cs and Ds because you were too busy reading "Tales from the Crypt" and Isaac Asimov, that's something entirely different. 3. On re-reading this I decided that it is true, but pretensious. If you like BASIC and program well in BASIC, then you should learn assembler and continue using BASIC. There are certain inherent difficulties with BASIC, so before you start you should read BAS1.DOC. This is on DISK2. The PC Assembler Tutor 4 ______________________ The PC Assembler Tutor - Copyright (C) 1989 Chuck Nelson All rights reserved Microsoft (R) Macro Assembler and Microsoft (R) Overlay Linker are registered trademarks of Microsoft Corporation. This manual contains screen output of the Macro Assembler and the Overlay Linker. Screen shots (C) 1981-1988 Microsoft Corporation. It also contains excerpts from Macro Assembler .LST files and Overlay Linker .MAP files. Portions of these files are Copyright (C) 1981-1988 Microsoft Corporation. Used with permission of Microsoft Corporation. TRADEMARK ACKNOWLEDGEMENT IBM is a registered trademark of International Business Machines Inc. Intel is a registered trademark of Intel Corporation. Macintosh is a registered trademark of Apple Computer, Inc. Microsoft is a registered trademark of Microsoft Corporation. Motorola is a registered trademark of Motorola, Inc. 8086 is a trademark of Intel Corporation. Codeview is a registered trademark of Microsoft Corporation. QuickC is a registered trademark of Microsoft Corporation. Turbo Pascal, Turbo Assembler and Turbo Debugger are registered trademarks of Borland International. The PC Assembler Helper was designed as a learning tool. It is meant to be used in conjunction with simple assembler programs to display the results of individual assembler instructions. It should not be used with high-level languages nor with programs that modify the screen. HELPMEM.COM, the memory resident version, uses the same interrupts as a debugger.