Preface

Theresas Schousek

Abstract

The purpose of the preface is to give a brief synopsis of the textbook and provide a light opening to the book. Two diagrams present the reader with an intro as to how assembly language fits within the larger scheme of programs. The author recalls her first foray into assembly language and its tight tie to the microcontroller’s architecture. The author reflects upon difficult and challenging work as actually fun and interesting, as well.

Keywords

Purpose; Scope; Program; Conversion; Mathematical; Numbering; Practical; Cost; Embedded; Control

Purpose and Scope

The purpose of this textbook is to give a thorough introduction to Microchip Assembly Language Programming for a wide range of users. Microchip’s most basic 33 instructions are used heavily throughout the text. It is recommended that the new user, regardless of 8-bit processor selection, self-restrict their use to the basic 33 instructions until these are second nature. This will prove to be the best approach to learning assembly language. This book provides a basic introduction to get the reader up to speed quickly. It provides beginning code development chapters on such things as basic data transfers, addition, and subtraction. Application notes for more complex mathematical routines, multiplication and division are presented for use as a practical solution. For the novice and returning programmers, there is also a chapter on Mathematical Numbering Systems. The chapters on arithmetic are reserved for the end of the book so as to not overwhelm the newest of users. Practical use and selection of specific evaluation boards, recommended by Microchip, is briefly presented with a cost, and feature, analysis.

Fundamentals of good design practice are presented using tried and true approaches of flowcharting, Warnier-Orr diagrams, and State Machines. In addition, a separate chapter is dedicated to SysML, by way of introduction, with a thorough case example. A new text on the market is recommended for those expecting to use SysML daily in their business.

The hardware interface is presented in a chapter on Embedded Control. Focus is on basic “electronic glue” used on 8-bit processors. Most of the interfaces can be used directly from this text. With only a modicum of electronic hardware changes, such as actual values of components, that will be required.

Program Conversion Process; from Program to Individual Bits

Complexity of computer programs is shown in Fig. 1. This diagram starts with the most fundamental element of a computer; the two states of 5 and 0 V. These are interpreted by the computer as a logical 1, for 5 V, and a logical 0, for 0 V or ground. The logical bits are then grouped by sequences of 8 bits, known as bytes. The binary strings are then grouped as clusters of 8 bits, or 1 byte; each byte defined by two hexadecimal digits from 0 through F. These binary strings are organized in groups of two nybbles; known as Machine Language. Each successive bubble, in Fig. 1, then introduces a higher level of programming. Assembly Language occupies the sweet spot between Machine Language and High level Language where knowledge of the embedded device is required and optimal efficient code can be produced.

Fig. 1
Fig. 1 The circle of languages and their position on the complexity scale.

The compiler converts a high level language such as C, C ++, FORTRAN, and Python into machine language. Each level of programming then requires “translation” ultimately to Machine Language, as shown in Fig. 2. This begins with Assembly Language, which is converted to Machine Language by the use of an assembler and linker. The linker is not a separate language, per se. It is a necessary step in the process of converting the program, as written by the user, into nybbles to be read by the computer.

Fig. 2
Fig. 2 Relationship between compiler, assembler, machine language, and linker.

Author’s Note

Congratulations, you have arrived! This is the greeting that I anticipated when first starting my journey into Assembly Language. Those who came before me learned assembly as their first language. Assembly was a rite of passage. I started programming with Basic, for the Commodore 64. Data Processing Class taught me FORTRAN, RPG II, COBOL, and Pascal.

There was a thirst for assembly, as some of us undertook manipulation of bits. I inherited a survey program. I was to expand the program so they could ask more questions. However, after pouring over the details in the program, I learned that the original author had taken the Yes/No questions, treated the answers as bit responses and made a single byte hold eight questions worth of binary answers. There would be no easy means of “just adding a couple more questions.”

I would not be given the opportunity to learn assembly in detail until my 4th year as a double major in Computer Engineering and Electrical Engineering. We emulated the PDP 11 with our programs. We learned the details of how a microprocessor works. Within this class, we wrote in assembly as we could gain unfettered access to control our micro. When you are seeking control of your processor, there is no better way to control it than to use Assembly Language.

However you come by this text, you will learn a new way of thinking before you are done. Assembly requires some nominal electrical engineering knowledge, in that you are intimately meshing your code with the operation of the processor. Electronic glue is introduced and fundamental electrical interface circuitry is presented. Usually, this takes the form of communication with a sensor or input from a switch. This is the heart of the microcontrollers’ functionality.

My approach is to be as thorough as possible, presuming no prior knowledge. Feel free to jump ahead if you have more background than the absolute beginner.

Dare We Call It Fun?

A few months back, I had the opportunity to talk with a neurologist. We happened upon a brief discussion of this text when I shared information on my work. He chuckled and then said he had programmed in assembly many years back. He even recalled the use of a rotate function to complete a multiply by two. Wistfully, he said “That was fun, really fun stuff.”

In recollection of this exchange, I have pondered this notion. Dare we call it fun? Throughout college engineering courses, I was so wrapped up in getting the next project done. I do not believe that I ever stopped to think of just how much fun I had in this course. I also really enjoyed Digital Logic; a course that I would later teach at a community college. Always remember, a course can be both difficult and fun.

Enjoy!

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.111.85