microcontroladores
; y guardar el resultado en la direccion 0x20
RESULTADO EQU 0X20
DATO1 EQU 0X10
DATO2 EQU 0X11
SUMA EQU 0X14
DIVISOR EQU 0X15
COCIENTE EQU 0X16
MOVLW 45
MOVWF DATO1
MOVLW D'62'
MOVWF DATO2
MOVLW D'0'
MOVWF SUMA
MOVLW D'3'
MOVWF DIVISOR
MOVLW D'0'
MOVWF COCIENTE;INICIO
MOVLW D'0' ; CARGAMOS EL REGISTRO DE TRABAJO CON 0
ADDWF DATO1,0
ADDWF DATO2,0
; GUARDAR LA SUMA
ADDWF SUMA,1
;DIVISION POR RESTAS SUCESIVAS
CICLO:
MOVF DIVISOR,W
SUBWF SUMA,1
INCF COCIENTE,1
MOVF SUMA,0
IORLW 0X0
BTFSC STATUS,C
GOTO CICLO
DECF COCIENTE,1
MOVF COCIENTE,0
MOVWF RESULTADO
END
datoA equ 0x0c
datoB equ 0x0d
datoC equ 0x0emult equ 0x0f
aux_mul equ 0x10
mostrar equ 0x11
resultado equ 0x12
d0 equ 0x13
d1 equ 0x14
d2 equ 0x15
numerador equ 0x16
dividendo equ 0x1A
divisor equ 0x1b
cociente equ 0x1c
residuo equ 0x1d
res_10 equ 0x1e
;*---------------------------------------------*
reset org 0x00
goto inicio
org 0x05
;rutina de multiplicacion
multiplicacion
clrfmult
ciclo_mult
addwf mult,1
decfsz aux_mul,1
goto ciclo_mult
movf mult,0
return
;rutina de division
division
clrf residuo
clrf cociente
ciclo_div
movf divisor,0
movwf aux_mul
movf cociente,0
call multiplicacion
subwf dividendo,0
btfss status,c
goto fin_divi
incf cociente,1
goto ciclo_div
fin_divi
decf cociente,1
movf divisor,0
movwfaux_mul
movf cociente,0
call multiplicacion
subwf dividendo,0
movwf residuo
return
;rutina visualizar display
visualizar
movlw .5
movwf mostrar
ciclo_v
movf d0,0
call tabla
movwf portb
bsf porta,0
call retardo_6.6ms
bcf porta,0
movf d1,0
call tabla
movwf portb
bsf portb,7
bsf porta,1
call retardo_6.6ms
bcf portb,7
bcf porta,1
movf d2,0call tabla
movwf portb
bsf porta,2
call retardo_6.6ms
bcf porta,2
decfsz mostrar,1
goto ciclo_v
return
;tabla de datos de salida
tabla
addwf PCL,1
retlw 0x3f
retlw 0x06
retlw 0x5b
retlw 0x4f
retlw 0x66
retlw 0x6d
retlw 0x7d
retlw 0x07
retlw 0x7f
retlw 0x6f
;rutina de retardo de 5ms
retardo_6.6ms
movlw .64
movwf 0x17
a2
movlw .33
movwf0x18
a1
decfsz 0x18,1
goto a1
decfsz 0x17,1
goto a2
return
;*------------------------------------------INICIO------------------------------------------------*
inicio
bsf status,rp0
clrf portb
movlw b'00010000'
movwf porta
bcf status,rp0
clrf resultado
clrf d0
clrf d1
clrf d2
;calcular
movlw .5
movwf datoA
movlw .5
movwf datoB
movlw .1movwf datoC
movf datoA,0
movwf aux_mul
movf datoB,0
call multiplicacion
movwf numerador
;division
movf numerador,0
movwf dividendo
movf datoC,0
movwf divisor
call division
movf cociente,0
movwf resultado
;llevando el rasultado a digito 0
movlw .10
movwf aux_mul
movf residuo,0
call multiplicacion
movwf res_10
movf res_10,0
movwf dividendomovf datoC,0
movwf divisor
call division
movf cociente,0
movwf d0
;llevando el rasultado a digito 1
movf resultado,0
movwf dividendo
movlw .10
movwf divisor
call division
movf residuo,0
movwf d1
movf cociente,0
movwf dividendo
call division
movf residuo,0
movwf d2
;consulta de inicio de conteo descendente
prog
call visualizar
btfss porta,4
gotoprog
descendente
call visualizar
decf d0,1
movf d0,0
sublw .255
btfss status,z
goto descendente
movlw .9
movwf d0
decf d1,1
movf d1,0
sublw .255
btfss status,z
goto descendente
movlw .9
movwf d1
decf d2,1
movf d2,0
sublw .255
btfss status,z
goto descendente
clrf d0
clrf d1
clrf d2
alarma
bsf porta,3
call visualizar
call...
Regístrate para leer el documento completo.