Programming the PIC Microcontroller with MBasic

Chapter 13 described the rudiments of assembler language, so it's now time to see how that knowledge may be used in MBasic. Our focus is not upon learning how to write complex assembler programs, but rather how to augment MBasic by adding a few lines of assembler here and there, making our programs run faster or access PIC features not otherwise available to us. This chapter provides a series of "bolt-in" replacements, simple assembler routines that may be directly substituted for MBasic statements. We will learn a process of stepwise refinement, where we replace MBasic statements one at a time, proceeding to the next statement only after verifying the earlier replacement.
We'll make frequent use of the word "macro" in this chapter, so let's first agree what a macro is. A "macro" in our context is a shortcut that is automatically expanded by the assembler into one or more real op codes.
Let's invent a macro for MBasic. MBasic doesn't allow user-defined macros, but we'll suppose it does. Our fictitious macro will save us from typing the full details to set up a For Next loop. It invoked as: @f v, s, f where v is the variable name, S is the start value for the loop and f is the final value. Thus, our fictitious macro permits us to enter the line @f i, 0,10. The compiler would then expand this macro shorthand into For i = 0 to 10 Next...