Last active
September 23, 2017 21:59
-
-
Save femoru/989bb91d3bfa837d10d2bb92b91fa2b9 to your computer and use it in GitHub Desktop.
Codigo de comparador para pic16f887
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;******************************************************+ | |
;* Autor: Felipe Moctezuma | |
;* Descripcion: Comparacion de 2 numeros binarios configurando los puertos de I/O | |
;* 3 bits de salida | |
;* 4 bits de entrada | |
LIST P=16F887 | |
#INCLUDE p16f887.inc | |
ORG 0 | |
GOTO CONF | |
CONF | |
BSF STATUS,5 ;PASO AL BANCO 1 | |
CLRF TRISD ;CONFIGURO LOS PUERTOS RE0-3 COMO SALIDA | |
MOVLW B'00001111' ;ESTABLESCO LOS PRIMEROS 4 BITS DE | |
MOVWF TRISB ;ESTABLESCO LOS PRIMEROS 4 BITS DE TRISA COMO ENTRADA | |
MOVWF TRISC ;ESTABLESCO LOS PRIMEROS 4 BITS DE TRISB COMO ENTRADA | |
BCF STATUS, 5 ;REGRESO AL BANCO 0 | |
GOTO LOOP | |
MAYOR | |
CLRF PORTD ;LIMPIA EL REGISTRO PORTD | |
BSF PORTD,2 ;PONE EN ALTO SOLO EL BIT 2 DE PORTD, PARA INDICAR QUE PORTB > PORTC | |
GOTO LOOP ;REGRESA A LOOP | |
MENOR | |
CLRF PORTD ;LIMPIA EL REGISTRO PORTD | |
BSF PORTD,0 ;PONE EN ALTO SOLO EL BIT 0 DE PORTD, PARA INDICAR QUE PORTB < PORTC | |
GOTO LOOP ;REGRESA A LOOP | |
IGUALES | |
CLRF PORTD ;LIMPIA EL REGISTRO PORTD | |
BSF PORTD,1 ;PONE EN ALTO SOLO EL BIT 1 DE PORTD, PARA INDICAR QUE PORTB > PORTC | |
GOTO LOOP ;REGRESA A LOOP | |
LOOP | |
MOVF PORTB,W ;MUEVE EL REGISTRO PORTB A W | |
SUBWF PORTC,W ;REALIZA LA OPERACION PORTC -PORTB Y LA ALMACENA EN W | |
BTFSC STATUS,Z ;EVALUA EL BIT Z DE STATUS PARA DETERMINAR SI LA OPERACION FUE 0,EN CASO QUE Z=1 SIGNIFICA QUE SON IGUALES | |
GOTO IGUALES ;ESCRIBE EN PORTE 010 QUE INDICA QUE SON IGUALES | |
BTFSS STATUS,C ;EVALUA EL BIT C DE STATUS PARA DETERMINAR SI LA OPERACION FUE POSITIVA O NEGATIVA,EN CASO QUE C=0 SIGNIFICA QUE PORTB > PORTC | |
GOTO MAYOR ;ESCRIBE EN PORTE 100 QUE INDICA QUE PORTB > PORTC | |
GOTO MENOR ;ESCRIBE EN PORTE 001 QUE INDICA QUE PORTB < PORTC | |
GOTO LOOP | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment