Nuestro 2do Proyecto (Motor p_p)
list p = 16f84
radix hex
estado equ 03
portA equ 05
portB equ 06
tmr0_op equ 01
reg0 equ 0c
reg1 equ 0d
reg2 equ 0e
reg3 equ 0f
org 00
bsf estado,5
movlw 10
movwf portA
movlw 0ff
movwf portB
movlw 07
movwf tmr0_op
bcf estado,5
inicio: movlw 01
movwf portA
jul1: movf portB,0
movwf reg0
andlw 03
movwf reg1
incf reg1,1
movf reg0,0
andlw 0f0
movwf reg2
swapf reg2,1
incf reg2,1
btfss portA,4
goto jul1
btfss reg0,4
goto jul2 ;es no del RB3
btfss reg0,3
goto jul3 ;es no del RB2 paso
ken1 call left
decfsz reg2,0
goto jul1
goto ken1
jul3: call right
decfsz reg2,0
goto jul3
goto jul1
jul2: btfss reg0,3
goto jul4 ;no de RB2 giro
ken3: call left
btfss portA,5
goto jul1
goto ken3
jul4: call right
btfss portA,5
goto jul1
goto jul4
right: movf reg1,0
sublw 01
btfsc estado,2
call rotar1
sublw 02
btfsc estado,2
call rotar2
sublw 03
btfsc estado,2
call rotar3
sublw 04
btfsc estado,2
call rotar4
return
left: movf reg1,0
sublw 01
btfsc estado,2
call rotar01
sublw 02
btfsc estado,2
call rotar02
sublw 03
btfsc estado,2
call rotar03
sublw 04
btfsc estado,2
call rotar04
return
rotar1: movlw 08
movwf portA
rrf portA,1
call delay1
btfss portA,4
goto jul1
goto rotar1
return
rotar2: movlw 08
movwf portA
rrf portA,1
call delay2
btfss portA,4
goto jul1
goto rotar2
return
rotar3: movlw 08
movwf portA
rrf portA,1
call delay3
btfss portA,4
goto jul1
goto rotar3
return
rotar4: movlw 08
movwf portA
rrf portA,1
call delay4
btfss portA,5
goto jul1
goto rotar4
return
rotar01 movlw 08
movwf portA
rrf portA,1
call delay1
btfss portA,5
goto jul1
goto rotar01
return
rotar02 movlw 08
movwf portA
rrf portA,1
call delay2
btfss portA,5
goto jul1
goto rotar02
return
rotar03 movlw 08
movwf portA
rrf portA,1
call delay3
btfss portA,5
goto jul1
goto rotar03
return
rotar04 movlw 08
movwf portA
rrf portA,1
call delay4
btfss portA,5
goto jul1
goto rotar04
return
delay1: movlw 08
movlw d'8'
movwf reg3
jon: btfss 0b,2
goto jon
bcf 0b,2
decfsz reg3,1
goto jon
return
delay2: movlw d'60'
movwf tmr0_op
jon1: btfss 0b,2
goto jon1
bcf 0b,2
return
delay3: movlw d'251'
movwf tmr0_op
jon2: btfss 0b,2
goto jon2
bcf 0b,2
return
delay4: movlw d'253'
movwf tmr0_op
jon3: btfss 0b,2
goto jon3
bcf 0b,2
return
end