Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "p16f877a.inc"
- ; CONFIG
- ; __config 0xFF7E
- __CONFIG _FOSC_XT & _WDTE_ON & _PWRTE_OFF & _BOREN_ON & _LVP_OFF & _CPD_OFF & _WRT_OFF & _CP_OFF
- ;NOTA EL OSCILADOR DEBE ESTAR EN XT POR QUE SE USARAN 4 MHZ 3- a 10 mhz
- ; nota, empa agregale la mascara al numero c ya que este es el de la eleccion 00000111B
- ; FALTA AGREGAR LAS ULTIMAS DOS OPCIONES, no recuerdo si era cuenta especial y rotabit
- ;custom equs0, procurar que esten en el banco 1
- numeroA EQU 0x20 ;
- numeroB EQU 0x21 ;
- numeroC EQU 0X22 ;eleccion
- contador EQU 0x23
- ParteAltaMul EQU 0x24
- Cociente EQU 0X25
- ;variables para contador por software
- Temporizador1 EQU 0X26
- Temporizador2 Equ 0x27
- Temporizador3 EQU 0X28
- org 0
- goto main
- ;Por ahi escuche que con 4 mhz el ciclo de ejecucion es de un micro segundo
- retardo250Micros:
- MOVLW 0XFA
- MOVWF Temporizador1
- LOOPTR0: DECFSZ Temporizador1
- GOTO LOOPTR0
- RETURN
- Retardo1Seg:
- MOVLW 0XFA
- MOVWF Temporizador2
- MOVLW 0X10
- MOVWF Temporizador3
- LOOPTR3:
- LOOPTR1: DECFSZ Temporizador2
- CALL retardo250Micros
- DECFSZ Temporizador3
- goto LOOPTR3
- RETURN
- ConfigurarMicro:
- MOVLW 0X20
- IORWF STATUS
- MOVLW 0XFF
- MOVWF TRISA ;puerto a como input
- MOVWF TRISB ;puerto b como input
- MOVLW 0x00
- MOVWF TRISC ;puerto c como output
- ; no hay nada mas que confifurar c:
- clrf STATUS
- RETURN
- get8bit:
- hold: BTFSS PORTA,0
- GOTO hold
- RELASE: BTFSC PORTA,0
- GOTO RELASE
- MOVF PORTB,W
- RETURN
- get3Nums:
- MOVLW 0X03
- MOVWF contador
- MOVLW numeroA ; puntero a la primera direccion de arreglo de numeros
- MOVWF FSR
- LOOP: CALL get8bit
- MOVWF INDF
- INCF FSR
- DECFSZ contador
- GOTO LOOP
- RETURN
- main:
- CALL get3Nums
- DECFSZ numeroC
- goto next
- ;opcion 1 suma
- MOVF numeroA,W
- ADDWF numeroB,W
- MOVWF PORTC
- goto ends
- next: DECFSZ numeroC
- goto next1
- ;opcion2 resta
- MOVF numeroB,W
- SUBWF numeroA,W
- MOVWF PORTC
- goto ends
- next1: DECFSZ numeroC
- goto next2
- ;opcion3 multiplicacion
- MOVLW 0X00
- LOOPMUL: DECFSZ numeroB
- goto breakloopmul
- ADDWF numeroA,W
- ;si hay carry sumarlo :P
- btfsc STATUS,C
- goto endCarryif
- INCF ParteAltaMul
- BCF STATUS,C ; limpiamos carry
- endCarryif:
- goto LOOPMUL
- breakloopmul:
- MOVWF PORTC
- goto ends
- next2: DECFSZ numeroC
- goto next3
- ;opcion 4 division
- CLRC
- MOVF numeroB,W
- DivisionLoop: SUBWF numeroA,1 ; que se vaya a f el resultado ojo 1 quiere decir f
- INCF Cociente
- BTFSC STATUS,C
- GOTO endDivisionLoop
- GOTO DivisionLoop
- endDivisionLoop:
- goto ends
- next3: DECFSZ numeroC
- goto next4
- ;OPCION 5 rotar el numero
- goto ends
- next4: DECFSZ numeroC
- goto ends
- ;opcion 6 Secuencia especial
- ends:
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement