Codigo Para El Pic de Carro en Assembler
-
Upload
df-gutierrez -
Category
Documents
-
view
1 -
download
0
description
Transcript of Codigo Para El Pic de Carro en Assembler
ALGORITMO CODIGO PARA EL PIC DE CARRO EN ASSEMBLER
//Codigo carro ASM
LIST P= 16f84A
INCLUDE<P16F84A.inc>
tmr0_opt EQU 1h; Registro compartido para TMR0(Banco 0) y OPTION_REG(Banco 1)
porta equ 05h ;registro del puerto A
portb equ 06h ;registro del puerto B
org 0x00
goto inicio
inicio bsf STATUS,RP0 ;se ubica en el segundo banco de la RAm
movlw B'1111'
movwf PORTA ;se programan los pines del puerto A
movlw B'0000'
movwf PORTB ;se programan los pines del puerto B
movlw 82h
movwf tmr0_opt
bcf STATUS,RP0 ;se ubica en el primer banco de la memoria RAM
PREGUNTA
movlw b'10000' ;activa bit 0 para que gire derecha
subwf PORTA
btfsc STATUS,2
goto DERECHA
movlw b'01000' ;activa bit 1 para que gire izquierda
subwf PORTA
btfsc STATUS,2
goto IZQUIERDA
movlw b'00100' ; bit en ceros para que siga adelante el carro
subwf PORTA
btfsc STATUS,2
goto ADELANTE
movlw b'00010' ; bit en ceros para que siga adelante el carro
subwf PORTA
btfsc STATUS,2
goto ATRAS
DERECHA
movlw b'00001001' ;bit 0 y 3 se activan en salida portb
movwf PORTB
bcf STATUS,2
goto PREGUNTA
ADELANTE
movlw b'00000101' ;bit 0 y 2 se activan en salida portb
movwF PORTB
bcf STATUS,2
goto PREGUNTA
IZQUIERDA
movlw b'00001010' ;bit 0 y 3 se activan en salida portb
movwF PORTB
bcf STATUS,2
goto PREGUNTA
ATRAS
movlw b'00000110' ;bit 0 y 3 se activan en salida portb
movwF PORTB
bcf STATUS,2
goto PREGUNTA
END