Programming the PIC Microcontroller with MBasic

Chapter 13: Assembler 101

At the end of this chapter, you won't be an expert in assembler language programming. In fact, if this is your first introduction to PIC assembler, you won't even qualify as a novice. What I hope to do, however, is to illuminate a few of the more important assembler programming principles to prepare the way for Chapters 14 and 15 where we will learn assembler routines that do things otherwise impossible with MBasic and speed up certain operations.

The Basics

Let's start with the basics. To keep the discussion to a manageable length, we'll limit our discussion to the 16F876/877/876A/877A series devices. For more details on these devices, as well as other PICs, consult the sources identified in the References section.

What is Assembler?

As we learned in Chapter 2, the MBasic programs you write are compiled into an assembler format, linked with library functions by a linker ultimately converted into machine instruction executable by a PIC.

Assembler is a human compatible form of directly addressing a PIC's built-in instruction set. A PIC's instruction set and mid-range PICs such as the 16F87x/87xA devices have only 35 instructions works with data and hardware at the most elementary level. Typical assembler instructions involve moving bytes from one storage location to another, or setting and clearing bits. Even the most complex mid-range PIC instructions do nothing more than add or subtract 8-bit values. Consequently, one line of MBasic code may correspond to dozens, or even hundreds of lines of assembler code.

We may illustrate this...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Programming Languages
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.