ok amigo este es el programa, como lo estoy colocando en el MicroCode!
ASM
CONTCL EQU 0X20
CONT EQU 0X21
eedig1 EQU 0X22
eedig2 EQU 0X23
eedig3 EQU 0X24
eedig4 EQU 0X25
LOOP2 EQU 0X26
dig_temp EQU 0X27
dig4 EQU 0X28
LOOP1 EQU 0X29
DIG2 EQU 0X2A
DIG3 EQU 0X2B
DIG1 EQU 0X2D
LOOP3 EQU 0X2E
inicio bsf 3,5
movlw 7
movwf adcon1
CLRF PORTD
MOVLW B"010000"
MOVWF PORTA
CLRF PORTE
CLRF PORTC
bcf Status,rp0
CLRF PORTA
CLRF PORTB
movlw .3
movwf contcl ;registro que cuenta los errores
lcd_inicio call p_lcd ;configuracion del LCD
call cls
movlw .100 ;como no posee RW se debe esperar un tiempo
movwf cont
dd nop
nop
nop
nop
nop
decfsz cont,1
b dd
call d_on_ci_off ;display on cursor off
call _2lineas ;doble linea
mensaje movlw "I" ;Mensaje por pantalla
call char ;de petición de clave
movlw "N"
call char
movlw "T"
call char
movlw "R"
call char
movlw "O"
call char
movlw "D"
call char
movlw "U"
call char
movlw "Z"
call char
movlw "C"
call char
movlw "A"
call char
movlw " "
call char
movlw "C"
call char
movlw "L"
call char
movlw "A"
call char
movlw "V"
call char
movlw "E"
call char ;TERMINA EL PRIMER MENSAJE
movlw 0xC6 ;segunda linea
call pos ;rutina de comando al LCD
movlw .4
movwf cont
clrf portb
movlw "1"
movwf eedig1
movlw "2"
movwf eedig2
movlw "3"
movwf eedig3
movlw "4"
movwf eedig4
;rutina de reconocimiento de clave
no_hay call initb ;configuracion del puerto B para teclado
call detec ;deteccion de tecla pulsada
movwf tecla
movlw 0xFF
subwf tecla,w
btfss status,z
goto no_hay
call codif
movwf tecla
call up_k
movf tecla,w
movwf dig_temp
lcd call P_LCD
call _2lineas
call d_on_ci_off
movlw b"00000110"
call mod
MOVF TECLA,W ;colocacion en el LCD de la tecla presionada
call char
decfsz cont,f
goto preg
movf dig_temp,w
movwf dig4
bsf 3,5
movlw b"10000111"
movwf option_reg
bcf 3,5
movlw .3
call _2_seg
goto comp
preg movlw .3
subwf cont,w
btfsc status,z
call uno
movlw .2
subwf cont,w
btfsc status,z
call dos
movlw .1
subwf cont,w
btfsc status,z
call tres
goto no_hay
uno movf dig_temp,w
movwf dig1
return
dos movf dig_temp,w
movwf dig2
return
tres movf dig_temp,w
movwf dig3
return
comp call p_lcd
call cls
movf eedig1,w
subwf dig1,w
btfss status,z
b clave_inc
movf eedig2,w
subwf dig2,w
btfss status,z
b clave_inc
movf eedig3,w
subwf dig3,w
btfss status,z
b clave_inc
movf eedig4,w
subwf dig4,w
btfss status,z
b clave_inc
goto bueno
infi b infi
clave_inc call p_lcd
call cls
decfsz contcl,1
b lcd_inicio
goto malo ;Cae aquí a la tercera vez
inft b inft
_10_ms movlw .100
movwf loop1
ss movlw .10
movwf loop2
ll nop
nop
nop
nop
nop
decfsz loop2,f
b ll
decfsz loop1,f
b ss
return
_2_seg movlw .200
movwf loop3
diez call _10_ms
decfsz loop3,f
b diez
return
malo BSF PORTA,1
GOTO MALO
BUENO BSF PORTA,2
GOTO BUENO
;=============================================
;=================librerias
;==========================lcd=============
cblock 0x40
var3
var4
endc
p_lcd bsf status,5
clrf portb
clrf portc
bcf status,5
return
cls movlw 0x01
call control
return
pos call control
return
mod call control
return
d_on_ci_off movlw b"00001100"
call control
return
funcion call control
return
control bcf portc,4
nop
movwf portb
nop
bcf portc,5
call del
bsf portc,5
nop
nop
return
char movwf portb
nop
bsf portc,4
nop
nop
bcf portc,5
nop
call del
bsf portc,5
nop
nop
return
del movlw d"8"
movwf var3
ciclo2 movlw d"8"
movwf var4
ciclo1 decfsz var4,f
goto ciclo1
decfsz var3,f
goto ciclo2
return
_2LINEAS movlw 0x38
call control
movlw 0xc
call control
return
;================================
;=====================================
;====================teclado=============
cblock 0x50
ptd
var1
var2
tecla
endc
initb clrf status
clrf portb
bsf status,rp0
movlw 0xf0
movwf portb
bcf status,rp0
return
;subrutina de deteccion de tecla presionada: regresa w=0 si no hay tecla presionada
; y w=0xff si hay alguna.
detec movlw 0xf0
movwf portb
btfss portb,7
goto rebo
btfss portb,6
goto rebo
btfss portb,5
goto rebo
btfss portb,4
goto rebo
retlw 0x0
rebo movlw d"100"
movwf var1
_b movlw d"40"
movwf var2
_a nop
nop
nop
nop
nop
decfsz var2,f
goto _a
decfsz var1,f
goto _b
btfss PORTB,7
retlw 0xff
btfss PORTB,6
retlw 0xff
btfss PORTB,5
retlw 0xff
btfss PORTB,4
retlw 0xff
retlw 0x0
;rutina para convetir en caracter ASCII
codif movlw 0xf7
movwf PORTB
btfss PORTB,7
retlw "1"
btfss PORTB,6
retlw "4"
btfss PORTB,5
retlw "7"
btfss PORTB,4
retlw "*"
movlw 0xfb
movwf PORTB
btfss PORTB,7
retlw "2"
btfss PORTB,6
retlw "5"
btfss PORTB,5
retlw "8"
btfss PORTB,4
retlw "0"
movlw 0xfd
movwf PORTB
btfss PORTB,7
retlw "3"
btfss PORTB,6
retlw "6"
btfss PORTB,5
retlw "9"
btfss PORTB,4
retlw "#"
retlw 0x00 ;falsa alarma ninguna tecla presionada
up_k movlw 0xf0
andwf PORTB,w
movwf ptd
movlw 0xf0
subwf ptd,w
btfss status,2
b up_k
return
end
ENDASM
INICIO:
HIGH PORTA.4
GOTO INICIO
END
==================================