;**********************************************************************
;   This file gives examples of simple macros and how to use them.    *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Filename:	    MacroUse.asm                                      *
;    Date:          February 6, 2006                                  *
;    File Version:  1                                                 *
;                                                                     *
;    Author:        CDR Charles B. Cameron                            *
;    Company:       United States Naval Academy                       *
;                                                                     * 
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files required:  p16f874.inc                                     *
;                                                                     *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:        None                                               *
;                                                                     *
;                                                                     *
;                                                                     *
;                                                                     *
;**********************************************************************


	list      p=16f874            ; list directive to define processor
	#include <p16f874.inc>        ; processor specific variable definitions
	
	__CONFIG _CP_OFF & _WDT_OFF & _BODEN_ON & _PWRTE_ON & _HS_OSC & _WRT_ENABLE_ON & _LVP_OFF & _CPD_OFF

; Watch dog timer is disabled by default.


;***** VARIABLE & MACRO DEFINITIONS

x_init	equ D'5'
x		equ H'20'
y_init	equ D'13'
y		equ H'21'

; The load macro loads a literal into a register.
load	macro	literal,register
	movlw	literal
	movwf	register
	endm

; The copy macro copies reg1's contents into reg2
copy	macro	reg1,reg2
	movf	reg1,W
	movwf	reg2
	endm


;**********************************************************************
		ORG     0x000             ; processor reset vector
		clrf    PCLATH            ; ensure page bits are cleared

	load	x_init,x

main
	copy	x,y
	movf	x,W
	addlw	D'7'
	movwf	y
	copy	y,x
	clrf	y

; remaining code goes here
	goto main
	
		END                       ; directive 'end of program'


