Allora, ho corretto qua e là un po' di errori, i più dovuti a errori di indentazione del codice (chissà cosa ne pensa il mio amico
carlomariamanenti 
)
Ecco qui:
- Codice: Seleziona tutto
;**********************************************************************
; This file is a basic code template for assembly code generation *
; on the PIC16F887. This file contains the basic code *
; building blocks to build upon. *
; *
; Refer to the MPASM User's Guide for additional information on *
; features of the assembler (Document DS33014). *
; *
; Refer to the respective PIC data sheet for additional *
; information on the instruction set. *
; *
;**********************************************************************
; *
; Filename: xxx.asm *
; Date: *
; File Version: *
; *
; Author: *
; Company: *
; *
; *
;**********************************************************************
; *
; Files Required: P16F887.INC *
; *
;**********************************************************************
; *
; Notes: *
; *
;**********************************************************************
list p=16f887 ; list directive to define processor
#include <p16f887.inc> ; processor specific variable definitions
; '__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, _LVP_OFF & _FCMEN_ON & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
__CONFIG _CONFIG2, _WRT_OFF & _BOR21V
;***** VARIABLE DEFINITIONS
w_temp EQU 0x7D ; variable used for context saving
status_temp EQU 0x7E ; variable used for context saving
pclath_temp EQU 0x7F ; variable used for context saving
;**********************************************************************
ORG 0x000 ; processor reset vector
nop
goto main ; go to beginning of program
ORG 0x004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
movf PCLATH,w ; move pclath register into w register
movwf pclath_temp ; save off contents of PCLATH register
; isr code can go here or be located as a call subroutine elsewhere
movf pclath_temp,w ; retrieve copy of PCLATH register
movwf PCLATH ; restore pre-isr PCLATH register contents
movf status_temp,w ; retrieve copy of STATUS register
movwf STATUS ; restore pre-isr STATUS register contents
swapf w_temp,f
swapf w_temp,w ; restore pre-isr W register contents
retfie ; return from interrupt
main
banksel 06h
clrf 06h ;inizializzazione port B
banksel 86h
movlw 07h ;RB<o;2> impostati come ingressi, RB<3;7> come uscite
movwf 86h
banksel 08h
clrf 08h ;inizializzazione port D
banksel 88h
movlw 00h ; port Dimpostato tutto come uscita
movwf 88h
banksel 81h
bcf 81h,07h ; abilitazione pull-up sul port B
banksel 06h
clrf 06h ; inizializzazione port B
banksel 95h
movlw 07h ; pull-up abilitati su RB<0;2>
movwf 95h
folle
btfsc 02h,06h ; test di RB2, finché è a 1 is sistema non parte
goto prima
banksel 08h
clrf 08h ; inizializzazione port D
banksel 88h
movlw 0xc0 ; RD<0;5> inpostati come ingressi, RD<6;7> come uscita
movwf 88h
goto folle
prima
btfss 01h,06h ; test di RB1, se è a 1 si è in prima, se è a 0 si è comunque in prima
goto primai
btfss 00h,06h ; test di RB0, se è a 1 si è in seconda, se è a 0 si rimane in prima
goto second
btfsc 02h,06h ; test di RB2, se è a 1 si è in prima, se è a 0 si va in folle
goto folle
primai
banksel 08h
clrf 08h ; inizializzazione port D
banksel 88h
movlw 0xF8
movwf 88h ; visualizzazione di 1 sul display
goto prima
seconda
btfss 01h,06h ; test di RB1, se è a 1 si è in seconda, se è a 0 si è in prima
goto primai
btfss 00h,06h ; test di RB0, se è a 1 si è in seconda, se è a 0 si è in terza
goto terzai
btfsc 02h,06h ; test di RB2, se è a 1 si è in seconda, se è a 0 si va in folle
goto folle
second
banksel 08h
clrf 08h ; inizializzazione port D
banksel 88h
movlw 24h ; RD<0,1,3,4,6,7> impostati come uscite, RD<2,5> impistati come ingressi
movwf 88h ; visualizzazione di 2 sul display
goto seconda
terza
btfss 01h,06h ; test di RB1, se è a 1 si è in terza, se è a 0 si è in seconda
goto second
btfss 00h,06h ; test di RB0, se è a 1 si è in terza, se è a 0 si è in quarta
goto quartai
terzai
banksel 08h
clrf 08h ; inizializzazione port D
banksel 88h
movlw 30h ; RD<0,1,2,3,6,7> impostati come uscite, RD<4,5> impostati come ingressi
movwf 88h ; visualizzazione di 3 sul display
goto terza
quarta
btfss 01h,06h ; test di RB1, se è a 1 si è in quarta, se è a 0 si è in terza
goto terzai
btfss 00h,06h ; test di RB0, se è a 1 si è in quarta, se è a 0 si è in quinta
goto quintai
quartai
banksel 08h
clrf 08h ; inizializzazione del port D
banksel 88h
movlw 19h ; RD<1,2,5,6,7> impostati come uscite, RD<0,3,4>impostati come ingressi
movwf 88h ; visualizzazione di 4 sul display
goto terza
quinta
btfss 01h,06h ; test di RB1, se è a 1 si è in quinta, se è a 0 si è in quarta
goto quartai
btfss 00h,06h ; test di RB0, se è a 1 si è in quinta, se è a 0 si è in sesta
goto sestai
quintai
banksel 08h
clrf 08h ; inizializzazione del port D
banksel 88h
movlw 12h ; RD<0,2,3,5,6,7> impostati come uscite, RD<1,4> impostati come ingressi
movwf 88h ; visualizzazione di 5 sul display
goto quinta
sesta
btfss 01h,06h ; test di RB1, se è a 1 si è in sesta, se è a 0 si è in quinta
goto quintai
btfss 00h,06h ; test di RB0, se è a 1 si è in sesta, se è a 0 si è comunque in sesta
sestai
banksel 08h
clrf 08h ; inizializzazione del port D
banksel 88h
movlw 20h ; RD<0,1,2,3,4,6,7> impostati come uscite, RD<5> impostato come ingresso
movwf 88h
goto sesta
END ; directive 'end of program'
; remaining code goes here
Rispetto al tuo, c'è qualche correzione. Ora, io non so cosa fa il tuo codice, anche perché l'hardware ce lo hai tu e solo tu puoi fare le prove. Copialo nel tuo progetto, così intendato come ho fatto io, compila e poi dimmi.
EDITLe correzioni, se non le hai individuate, sono in queste righe:
- Codice: Seleziona tutto
movlw 0xc0 ; RD<0;5> inpostati come ingressi, RD<6;7> come uscita
e
- Codice: Seleziona tutto
movlw 0xF8
Quando usi la istruzione movlw seguito da un valore esadecimale maggiore o uguale di A0, devi far scrivere l'istruzione in due modi:
- Codice: Seleziona tutto
;così
movlw 0F8h;
; oppure
movlw 0xF8
Ciao.
Paolo.
P.S. Ho rimosso anche queste righe, perché prive di senso:
; example of preloading EEPROM locations
ORG 0x2100
DE 5, 4, 3, 2, 1