Limiting Factors

Due to the structure of the resulting assembly file and the PIC18 architecture there are a few limiting factors that the programmer needs to keep in mind.


Calling procedures from interrupts and recursion

Due to the way local variables are allocated without a real software stack Basic18 procedures are not reentrant, therefore recursion is not possible.

There are three threads of execution possible on the PIC18

A procedure called from one of these threads can not be called by another thread.  This includes library routines explicitly called by the user, or automatically called by the compiler.

The compiler will call library routines to perform the following operations, therefore these operations are only allowed in one thread of execution.

  • All division operations
  • All Modulus operations
  • 8, 16, 24, and 32 bit signed multiplication
  • 16, 24, and 32 bit unsigned multiplication
  • Most Shl and Shr instructions
  • Floating point operations, including comparisons
  • On x Goto
  • On x Gosub
  • Literal string assignments  IE:  strVar = "abc"
  • Max and Min functions

Limited branching distance

Because Basic18 takes advantage of the advanced instruction set of the PIC18 for generating comparisons, the amount of code contained inside some control structures are limited to 127 bytes.  The compiler will not generate an error for this, however the assembler will generate errors when the program is assembled.

If Then / End If

Code space between If Then and the End If can not exceed 127 bytes.

If Then / Else / End If

Code between  If Then and Else can not exceed 127 bytes.

While / End While

Code between While and End While can not exceed 127 bytes

 

The following structures are not effected by this limitation


Boolean = Boolean

When assigning the contents of one boolean variable to another, both variables MUST be in the same RAM Bank.