;YOU NEED TO COPY AND PASTE THIS INTO YOUR MPLAB DOCument AND ;SAVE IT AS A .ASM FILE ;******************************************************************* ; TITLE: New 16C84 project ; AUTHOR: ; DATE: ;******************************************************************* ;State here what the program does ;********************************************************************* ; DEFINITIONS ;********************************************************************* list P=PIC16C84, R=D ;Define PIC type and radix ;(H=Hex, D=Decimal). Hex numbers must ;be of the form 0xAA or 0AAh include "P16C84.INC" ;P16C84.INC is a file containing ;definitions of PIC registers ;****** REGISTER USAGE ****** ;For PIC16C84, user RAM starts at 0Ch. The following definitions ;(the names are arbitrary) will be found useful in many programs. temp1 equ 0Ch ;Temporary register 1 temp2 equ 0Dh ;Temporary register 2 count equ 0Eh ;Counter register ;********************************************************************* ; VECTORS ;********************************************************************* ;The PIC16C84 vectors live at the bottom of memory (0000h-0007h) org 0000h ;Reset vector for PIC16C84 is at 0000h goto start ;Go to main program start org 0004h ;Interrupt vector for PIC16C84 is at ;0004h goto inter ;Go to start of interrupt service ;routine org 0008h ;first location available to programs ;********************************************************************* ; SUBROUTINES ;********************************************************************* ;By convention, subroutines are placed after the vectors so that they ;are at the bottom of memory. This avoids memory bank-switching for ;small programs. ;Code for subroutines goes here ;********************************************************************* ; MAIN PROGRAM ;********************************************************************* ;****** INITIALISATION ****** ;Before using the I/O ports, the data direction registers must be set ;up. Bit RP0 in the status register selects either the normal register ;set when 0, or the special register set when 1. The data direction ;registers TRISA and TRISB live in the special register set. A '1' in ;these registers sets the corresponding port line to an Input, and a ;'0' makes the corresponding line an output. start bsf STATUS,RP0 ;select special register set movlw b'11111' ;set port A data direction to 'all I/P' movwf TRISA movlw b'00000000' ;set port B data direction to 'all O/P' movwf TRISB bcf STATUS,RP0 ;select normal register set ;****** MAIN PROGRAM ****** ;The code for the main program goes here ;********************************************************************* ; INTERRUPT SERVICE ROUTINE ;********************************************************************* ;The interrupt service routine (if required) goes here inter END ;all programs must end with this