list p=pic16f84a
include "p16f84a.inc"
__config _hs_osc & _wdt_off & _pwrte_off & _cp_off
page1 equ 0c
page2 equ 0d
page3 equ 0e
page4 equ 0f
temp equ 10
cnt equ 12
cntl equ 13
org 0
goto init
init
bsf status,rp0 ;Change to Bank1
movlw b'00000000' ;
movwf trisa ;Set porta to Output mode
movlw b'11111111' ;
movwf trisb ;Set portb to Input mode
bcf option_reg,7 ;portb pull up enable
bcf status,rp0 ;Change to Bank0
clrf porta ;led off
scan
P1 bcf porta,0
bcf porta,1
nop
nop
nop
nop
movf portb,0
movwf page1
P2 bsf porta,0
bcf porta,1
nop
nop
nop
nop
movf portb,0
movwf page2
P3 bcf porta,0
bsf porta,1
nop
nop
nop
nop
movf portb,0
movwf page3
P4 bsf porta,0
bsf porta,1
nop
nop
nop
nop
movf portb,0
movwf page4
bsf page4,0
bsf page4,1
search movlw b'11111111'
andwf page1,0
andwf page2,0
andwf page3,0
andwf page4,0
movwf temp
bsf temp,4
btfss temp,0
bcf temp,4
btfss temp,1
bcf temp,4
btfss temp,2
bcf temp,4
btfss temp,3
bcf temp,4
led btfss temp,4
bsf porta,2 ;ledon
btfsc temp,4
bcf porta,2 ;ledoff
send call start
call dat
call finish
goto scan
start call yess ;100order
call nos ;100order
call yess ;100order
call nos ;100order
return
dat
btfss page1,0 ;----z
call yes ;
btfsc page1,0 ;200order
call no ;-----
btfss page1,1 ;y
call yes
btfsc page1,1
call no
btfss page1,2 ;x
call yes
btfsc page1,2
call no
btfss page1,3 ;r
call yes
btfsc page1,3
call no
btfss page2,0 ;b
call yes
btfsc page2,0
call no
btfss page2,1 ;c
call yes
btfsc page2,1
call no
btfss page2,2 ;a
call yes
btfsc page2,2
call no
btfss page2,3 ;s
call yes
btfsc page2,3
call no
btfss page3,0 ;up
call yes
btfsc page3,0
call no
btfss page3,1 ;down
call yes
btfsc page3,1
call no
btfss page3,2 ;left
call yes
btfsc page3,2
call no
btfss page3,3 ;right
call yes
btfsc page3,3
call no
btfss page4,3 ;l
call yes
btfsc page4,3
call no
return
finish
bcf porta,3
call waitl
return
yess bsf porta,3 ;yess has 98 orders
call wait
return
nos bcf porta,3 ;nos has 98 orders
call wait
return
yes bsf porta,3 ;yes has 195 orders
call wait
call wait
nop
nop
return
no bcf porta,3 ;no has 195 orders
call wait
call wait
nop
nop
return
waitl movlw d'30' ;waitl has 12003 orders
movwf cntl ;number of order = 3+400*30
waitld call wait
decfsz cntl,1
goto waitld
return
wait movlw d'30' ;wait has 93 orders
movwf cnt ;number of order = 3+3*30
waitd decfsz cnt,1 ;one bit width equals 200 orders
goto waitd
return
end
Index
メスを使わない二重術でステキな笑顔になりませんか?