;********************************************************************** ; Program or Assignment Title: ; Second Program ;Date: 10/12/2009 ;Programmer Name: Corey ;********************************************************************** list p=16f887 ; list directive to define processor #include ; processor specific variable definitions radix hex errorlevel -302 ;Disable bank warning message in error list ; '__CONFIG' directive is used to embed configuration data within .asm file. ; The labels following the directive are located in the respective .inc file. ; See respective data sheet for additional information on configuration word. __CONFIG _CONFIG1, _HS_OSC & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _CPD_OFF & _BOR_ON & _IESO_ON & _FCMEN_ON & _LVP_OFF & _DEBUG_OFF __CONFIG _CONFIG2, _BOR40V & _WRT_OFF ;Note: All of the CONFIG designations must be contiguous on one line for each config register ;1 & 2. ;********************************************************************** ;Register Equates go here cblock 0x9F WALK endc ;---------------------------------------------------------------------- ;Macro to select data bank 0 selbank0 macro bcf STATUS, RP0 bcf STATUS, RP1 endm ;Macro to select data bank 1 selbank1 macro bsf STATUS, RP0 bcf STATUS, RP1 endm ;Macro to select data bank 2 selbank2 macro bcf STATUS, RP0 bsf STATUS, RP1 endm ;Macro to select data bank 3 selbank3 macro bsf STATUS, RP0 bsf STATUS, RP1 endm ;--------------------------------------------------------------------- ORG 0x000 goto start ORG 0x005 start selbank1 movlw 0x00 ;load w with all zeros movwf TRISB ;Set PORTB direction bits to outputs ;--------------------------------------------------------------------- movlw 0xFF movwf WALK ;store 0xFF in 0x9F (whose first write will be to 0xA0 due to increment) ;--------------------------------------------------------------------- ;stay in bank1 for access to A0h - EFh movf WALK ; movwf FSR ;set FSR to 0x9F loop movf INDF,W ;reads whatever is in 0x9F into W incf FSR,F ;increments FSR (not points to 0xA0) movwf INDF ;writes W to 0xA0 movlw 0xA9 ;check for last register xorwf INDF,W ;compare to 1 past last register btfss STATUS,Z ;keep looping if not there yet goto loop ;loop to write again selbank0 ;back to bank zero movlw 0xFF ;load W with all ones movwf PORTB ;light all portb LEDS when done quit goto quit ;loop forever! ;===================================================================== END ; directive 'end of program'