<<Previous

Next>>

6. Structure of a Compiled Program

PBP is designed to be easy to use. Programs can be compiled and run with little thought to PBP's internal workings. Some people, however, only have confidence in a product when they understand its internal workings. Others are just plain curious.

This section is for them. It describes the files used and output generated by PBP and gives some idea of exactly what is going on.

6.1. Target Specific Headers

Three target specific header files are used when a program is compiled. One is used by PBP, the other two are included for use by the assembler.

A file with the name of the microcontroller followed by the extension .BAS contains chip specific information needed by PBP. This includes the memory profile of the chip, which library it uses, and includes for the definition of the variables it needs. For the PIC16F84, the default microcontroller, the file is named 16F84.BAS.

A file with the name of the microcontroller followed by the extension .INC is included in the generated .ASM file to give the assembler information about the chip, including the default configuration parameters (oscillator mode, Watchdog Timer setting, etc.). For the PIC16F84, the file is named 16F84.INC.

Finally, the assembler has its own include file that defines the addresses of the microcontroller registers. This file is usually named something on the order of M16F84.INC. and is in the INC directory.

6.2. The Library Files

PBP includes a set of library files that contain all of the code and definition files for a particular group of microcontrollers. In the case of 14-bit core PICmicros, these files start with the name PBPPIC14.

PBPPIC14.LIB contains all of the assembly language subroutines used by the compiler. PBPPIC14.MAC contains all of the macros that call these subroutines. Most PICBASIC PRO™ commands consist of a macro and an associated library subroutine.

PBPPIC14.RAM contains the VAR statements that allocate the memory needed by the library.

PIC14EXT.BAS contains the external definitions that tells PBP all of the 14-bit core PICmicro register names.

6.3. PBP Generated Code

A PICBASIC PRO™ compiled program is built in several stages. First PBP creates the .ASM file. It then builds a custom .MAC file that contains only the macros from the macro library that are used in the .ASM file. If everything is error free up to this point, it spawns the assembler.

The assembler generates its own set of files. These include the .HEX final output file and possibly listing and debugging files.

6.4. .ASM File Structure

The .ASM file has a very specific structure. Things must be done in a particular order for everything to work out properly.

The first item placed in the file is an equate defining which assembler is to be used, followed by an INCLUDE to tell the assembler which microprocessor is the target and give it some basic information, such as the configuration data.

Next, all of the variable allocations and aliasing is listed. EEPROM initialization is next, if called for.

An INCLUDE for the macro file is then placed in the file, followed by an INCLUDE for the library subroutines.

Finally, the actual program code is incorporated. This program code is simply a list of macros that were generated from the PICBASIC PRO™ lines.

<<Previous

Next>>