PIC 16Cxx Assembler This document describes the technical aspects of the PIC16Cxx Assembler/Linker (MPALC) developed by Microchip Technology Incorporated. Included in this manual is a list of main features, program structure, directives, macro capabilities, I/O files, and a detailed description of the instruction sets for the PIC16C5X and PIC16CXX. Based on the instruction width, 16C5X family processors are sometimes referred to as 12 bit core machines, and 16CXX processors are referred to as 14 bit core machines. The file "MPALC.DOC" on the software tools diskette provides any updates or additional information which was not available at the time this User's Guide was printed. 1.1 CONCEPTS An assembler is a software development tool used to translate a set of assembler instructions (called source code) into instructions that are understood by the computer (called machine code). Assembler instructions are provided as an easy means by which a programmer can effectively execute machine instructions. The complete PIC Assembly language is comprised of the following three components: . Instruction mnemonics . Directives . Macros Mnemonics are instructions that are translated directly into machine code. They are used to perform arithmetic and logical operations on data residing in either memory or registers. They also have the ability to move data in and out of registers and memory as well as conditional branching to specified program addresses. Directives provide control of the assembler's operation by telling the assembler how to treat mnemonics, reference data, and format the listing and output files. Directives make coding easier and provide custom output tailored to the project's needs. A macro consists of a sequence of assembler commands. Passing arguments to a macro allows for flexible functionality of the macro. They provide the following advantages: . Higher level of abstraction which in turn improves readability, simplicity of implementation and greater reliability. . Consistent solution to a frequently performed function. . Simplify changes because changing a macro body is easier than modifying all locations where a given function is performed. 1.2 MAIN FEATURES OF MPALC - OVERVIEW . Translates programs (source code) written in PIC Assembly language to machine executable code (object code) on IBM PC or compatibles running MS-DOS V3.31. . Generates object code in 4 different formats to accommodate third party EPROM programmers and Microchip's PIC development tools. . Accepts source code and generates object code for Microchip's proprietary PIC microcontroller families including the PIC16C54, PIC16C55, PIC16C56, PIC16C57, PIC16C71 and PIC16C84. . Provides full featured MACRO capability. . Supports Hex (default), Decimal and Octal source and listing formats. . Provides conditional assembly capability. 1.3 ADDITIONAL INFORMATION Occasionally it may be necessary to distribute additional information about MPALC after the documentation has been published. This might include corrections and additions to the document, examples and applications, or bug reports. If this information is included, it will be found in the file "MPALC.DOC" on the software tools diskette. The appendix to this document entitled "Keeping Current" contains information about the Microchip Technology systems bulletin board service. This is another way that you can maintain the most up-to-date software support tools. The following is a list of related documents; . PIC16C5X Data Sheet (DS30015) . PIC16C71 Data Sheet (DS30150) . PIC16C84 Data Sheet (DS30081) This chapter provides instructions on how to install and run MPALC on your PC. We strongly suggest that this chapter be read in its entirety before using MPALC. It is a guide to the initial setup and running of the assembler, and discusses system dependent features. 2.1 SYSTEM REQUIREMENTS MPALC will run on any IBM PC/AT or compatible computer, running MS-DOS v3.31 or greater. The distribution medium is 5 1/4" low density (360k) floppies. No special display or ancillary devices are required. 2.2 INSTALLATION MPALC is distributed on a 5 1/4" floppy disk and is at the root directory level. It may be executed directly from the floppy by typing: a:MPALC for example. You may want to copy MPALC to your hard disk for convenience. This can be done by using the DOS "COPY" command to place it in the desired directory. For example, you might execute the following at the DOS prompt: mkdir c:\MPALC copy a:*.* c:\MPALC\. You may then include MPALC in your search path by updating the "PATH" variable in your "AUTOEXEC.BAT" to include this directory. This allows the programs to be accessed from any directory on your system. Please refer to your DOS manual for more information regarding DOS commands, the "PATH" environment variable and the "AUTOEXEC.BAT" file. Remember that changes that you make to this batch file will not take effect until the next time you boot your machine or execute autoexec.bat. 2.3 INVOKING MPALC The assembler is invoked with the following command: MPALC [options] where is the file to be assembled and [options] may be: [/?] [/p ] [/f ] [/w ] [/w- [/r ] [/t ] [/i] [/d label_name=label.value] ù Commands in brackets [ ] are optional. ù Spaces are required between each option. ù All source files are assumed to have the '.ASM' extension. Any other extension must be explicitly given. /? displays a brief help screen describing the command line options. The assembler exits immediately after printing the help screen. /p specifies the processor type to use during assembly. may be 16C54, 16C55, 16C56, 16C57, 16C71 or 16C84. The default is 16C54. /f specifies the output format for the object file. may be INHX16, INHX8S, INHX8M or PICICE. The default is INHX16. /w specifies level of warnings to be reported in the listing. There are four increasing levels of messages defined in MPALC: comments, warnings, fatal and criticals. may be 0 (Comments), 1 (Warnings), 2 (Fatals) or 3 (Criticals). If the user sets the level of message reporting, all messages above and including the level desired will be reported, i.e. if 'w 2' is specified, then only 'FATAL" and "CRITICAL" messages will be reported. If this switch is not used, the warning level will default to 1. /w- specifies error message to delete from listing. Note that there is no space between the '-' and the error code. may be any number between 0 and 64. You may list as many of this option on the command line as space will allow, 1 error code/w- option. See Appendix B for error messages and thier corresponding codes. /r specifies the default radix for constants during assembly. may be DEC, OCT or HEX. The default is HEX. /t specifies tabs in the source file should be replaced by spaces. is the number of spaces used to replace a tab. /i specifies all symbols will be case insensitive. By default symbols are case sensitive. /d defines a label and its value. When generating programs for a family of products, command line labels can be used to control conditional assembly directives or to set critical constants without having to edit the original source code. PIC-ICE Produces files to be compatible with PIC-ICE Emulator. In this format, no assembler messages will be present in the listing file including TITLEs and SUBTITLEs. However, all warning messages will be seen on the display device. INHX8S Produces two 8-bit Hex files, one for the high order 8 bits and the other for the low order 8 bits. File extensions for object code will be '.obl' and '.obh' for low and high order files respectively. This format is particularly useful for generating EPROMs. INHX8M Produces one merged Intellec Hex file with a low-byte high-byte combination. This format is particularly useful for downloading PIC16C5X code to third party EPROM programmers (Unisite DATA I/O, ALLPRO Logical Devices). INHX16 Produces one 16-bit Intellec Hex file. This format is used by Microchip's "PICPRO" programmer. The Assembler produces various output files with the following extensions: . OBJ - Object file . OBH - Address/Data pairs for high-order 8 bits (only when INHX8S format selected) . OBL - Address/Data pairs for low-order 8 bits (only when INHX8S format selected) . LST - Listing file . ERL - Error and warning message file . SYM - Symbol file (produced with INHX16 and INHX8M formats . REF - Symbol reference file (only produced with PIC- ICE output format) . MAP - PIC-ICE binary debug file (only produced with PIC-ICE output format) 2.5 ASSEMBLER SOURCE LINE FORMAT Assembler source code statements are divided into four basic fields: . the label field . command field . operand field . comments field. The general format for a program source line is: [