📄 amy.asm
字号:
option
call timer2ms
call timer
btfss flag1,time_15
goto lcd_upd
bsf status,6
;;wu bcf status,5
goto stop
;====================================
;lcd update
lcd_upd
clrf fsr
bsf status,5
;; bcf status,6
movlw 0a0; com 101
movwf temp1
bcf flag1,finish
movlw 03
movwf send_num
call spi_send
movlw 70h
movwf fsr
movwf temp2
movf temp2,w
andlw 1f ;lcd addr
movwf temp1
movlw 6
addwf temp1,f
rlf temp1,f
rlf temp1,f
clrf fsr
bcf flag1,finish
movlw 06
movwf send_num
call spi_send
lcd_cont
movf temp2,w
movwf fsr
movf 0,w
movwf temp2 ;just for temperary ram
clrf temp1
btfsc temp2,0
bsf temp1,7
btfsc temp2,1
bsf temp1,6
btfsc temp2,2
bsf temp1,5
btfsc temp2,3
bsf temp1,4
movf fsr,w
movwf temp2 ;save the fsr
clrf fsr
;bsf flag1,finish
movlw 04
movwf send_num
bsf status,5
call spi_send
bcf status,5
incf temp2,f
dspl_next
movlw 0f9h ;due to fsr.7==1
xorwf temp2,w;fsr,w
btfss status,z
goto dspl_next1;lcd_cont
bsf flag1,finish
goto lcd_cont
dspl_next1
movlw 0fah
xorwf temp2,w
btfss status,z
goto lcd_cont
clrf fsr
btfsc flag7,lcd_init ;wu
goto ret4_ ;
bsf status,5
;; bcf status,6
goto key
;end of lcd_upd
ret4_
bcf flag7,lcd_init
bsf status,5
bsf status,6
goto ret4 ;wu
;-------------------------;wu
auto_mode
btfss flag2,auto
goto auto_ok1
btfss flag7,a_pause
goto a001
a11 btfsc flag7,a_step
goto a12
btfss flag7,a_timerb
goto a13
bsf flag7,a_step
bcf status,c
rlf mode,f
a111 bsf flag7,a_pause ;used in position detect
bcf flag7,a_timerb
movlw d'50'
btfsc mode,2
movlw d'90'
movwf a_timer
btfss mode,3
goto a112
movlw b'00000010'
movwf mode
a112 goto a_mode_set
;;a112 btfsc flag7,a_step
;; goto a_mode_set
;; goto auto_ok1
a12 btfss flag7,a_step
goto auto_ok1
btfss flag7,a_timerb
goto a13
bcf flag7,a_timerb
bcf flag7,a_pause
btfss flag7,a_yaobu
goto a_mode_c
bcf flag7,a_yaobu
bsf status,6
goto auto_mode_x
a13 btfss mode,2
goto auto_ok1
movlw d'30'
xorwf a_timer,w
btfsc status,z
goto w_cg
movlw d'60'
xorwf a_timer,w
btfss status,z
goto auto_ok1
w_cg bsf status,6
goto w_change
a001 btfss flag5,xxw
goto a01
bsf flag7,a_yaobu
bcf flag7,a_jingbu
goto auto_ok1
a01 btfss flag7,a_yaobu
goto a02
bcf flag7,a_step
goto a111
a02 btfsc flag7,a_jingbu
goto auto_ok1
btfss flag3,xx
goto auto_ok1
movlw 0f ;0ch ;????
xorwf xc_counter2,w
btfss status,z
goto auto_ok1
bsf flag7,a_jingbu
bcf flag7,a_step
goto a111
auto_ok1
bsf status,6
goto auto_ok
a_mode_c
bsf status,6
goto auto_mode_c
a_mode_set
bsf status,6
goto auto_mode_set
;================================
org 200
;================================
spi_send
clrf fsr
bcf portc,spi_cs ;/cs become low
nop
bcf status,c
conts bcf portc,spi_wr ;spi_wr=portc.2
rlf temp1,f
btfss status,c
bcf portc,spi_data ;spi_data=portc.1
btfsc status,c
bsf portc,spi_data
nop ;call delay2
bsf portc,spi_wr ;write data
nop ;call delay2
decfsz send_num,1
goto conts
btfss flag1,finish
goto back_
bsf portc,spi_cs
nop ;call delay2
back_ retlw 00
;---------------------------------
;+++++++scankey+++++++++++++++++++
scan_key
movlw 1
movwf portc
movlw 0f0h
tris portc ;`11110000`,
;nop
keyid
movlw 3 ;00000011 ,line1
movwf portc
nop
movf portc,w
andlw 0f0h
movwf temp1
movlw 0
xorwf temp1,w
btfsc status,z
goto line2
swapf temp1,f
movlw 10h
addwf temp1,f ;18=k9,14=k7,12=k4,11=k1
goto scan_ok
line2 movlw 5 ;00000101 ,line2
movwf portc
nop
movf portc,w
andlw 0f0h
movwf temp1
movlw 0
xorwf temp1,w
btfsc status,z
goto line3
;movwf temp1
swapf temp1,f
movlw 20h
addwf temp1,f ;28=k10,24=k8,22=k5,21=k2
goto scan_ok
line3 movlw 9 ;00001001,line3
movwf portc
nop
movf portc,w
andlw 0f0h
movwf temp1
movlw 0
xorwf temp1,w
btfsc status,z
goto scan_ok
;movwf temp1
swapf temp1,f
movlw 30h
addwf temp1,f ;32=k6,31=k3
scan_ok
movlw 1
movwf portc
movlw 0
tris portc
retlw 0
;=================================
key
btfss flag2,key_down
goto check_key ;no key down,go to check key
btfsc flag2,key_processed
goto judge_up
btfsc flag1,key_time
goto key1
goto process_ok;check_end_position1
key1
bcf flag1,key_time
call scan_key
movf temp1,w
subwf key_buffer,w
btfss status,z
goto no_key_down
bsf flag2,key_processed
;bcf status,6
;bsf status,5
goto processed_key
;------------------------------------
check_key
call scan_key ;some key down
movf temp1,w
btfsc status,z
goto no_key_down
movwf key_buffer
bsf flag2,key_down
goto key_over
;------------------------------------
no_key_down
bcf flag2,key_down
bcf flag2,key_processed
clrf key_buffer
key_over
goto process_ok;check_end_position1
;--------------------------------------------
judge_up
movlw 1
movwf portc
movlw 0f0h
tris portc
nop
movlw 0fh
movwf portc
nop
;nop
movf portc,w
andlw 0f0h
xorlw 0
btfss status,z
goto key_no_up
movlw 22 ;key up
subwf key_buffer,w
btfss status,z
goto up1
bcf flag2,x_on
bcf flag3,sx
goto up2
up1 movlw 32
subwf key_buffer,w
btfss status,z
goto up2
bcf flag2,x_on
bcf flag3,xx
up2 clrf key_buffer
bcf flag2,key_down
bcf flag2,key_processed
key_no_up
movlw 1
movwf portc
movlw 0
tris portc
goto process_ok;check_end_position1
;+++++++++++++++++++++++++++++++++++++++++++++++
processed_key
movlw beig_counter
movwf fsr
movlw d'90'
movwf indf
clrf fsr
bsf flag5,beig
;-------------------------------
k2 ;on/off (wu)
movlw 21h ;k2
subwf key_buffer,w
btfss status,z
goto f_k1
btfsc flag1,qd
goto all_stop
bsf flag1,qd
;movlw 3
;movwf mode
;bsf flag5,zhong
;bsf flag7,jcqq
goto process_ok
all_stop ;wu???
;; bcf flag2,x_on
;; bcf flag1,qd
movlw 0f8h
movwf ds_counter1
clrf ds_counter2
bsf status,6
bcf status,5
goto stop
;----------------------------------------------
f_k1 btfss flag1,qd ;(wu)
goto process_ok
k1 ;auto(wu)
movlw 11h ;k1
subwf key_buffer,w
btfss status,z
goto k3
btfsc flag2,auto
goto xz_stop
;; bsf flag1,qd
bsf flag2,auto
bcf flag7,a_yaobu
bcf flag7,a_jingbu
bcf flag5,zhong
bsf flag5,kuan ;wu
bcf flag5,zhai ;wu
movlw mode_ct
movwf fsr
movlw b'00001000'
movwf indf
clrf fsr
movlw b'00001000' ;3
movwf mode
btfss flag3,rf
goto k1_1
bcf flag3,rf
bsf flag7,jcqq1
goto k8a ;!!!
k1_1
bsf flag3,rz
bsf flag7,jcqq
goto k8a ;!!!
xz_stop
bcf flag2,auto
bcf flag2,x_on
bcf flag2,end_position
bcf flag3,sx
bcf flag3,xx
bcf flag3,xshx
bcf flag3,xxhx
bcf flag3,dwxy
clrf qujian
clrf flag4
clrf flag6
bcf flag2,z2_ds
bcf flag5,z2_dx
movlw 83h
andwf flag7,f ;wu clear auto flag bits
movlw 0ah
movwf end_key_counter
goto process_ok
;--------------------------------
k3 ;mode
clrf fsr
btfsc flag2,auto
goto k4 ;(wu)process_ok
movlw 31h
subwf key_buffer,w
btfss status,z
goto k4
btfsc flag3,rfhx
goto process_ok
btfsc flag3,rzhx
goto process_ok
bsf flag1,qd
;; incf mode,f
movf mode,w
addwf mode,f
;; movlw 4
;; subwf mode,w
btfss mode,4 ;status,z
goto k31
movlw b'000000010' ;1
movwf mode
k31 ;movlw 1
;subwf mode,w
btfss mode,1 ;status,z
goto k32
;wu bcf flag5,kuan
; bcf flag5,zhong
; bcf flag5,zhai
bsf flag3,rz ;mode3-->mode1 or 0-->mode1
bcf flag3,rf
goto process_ok
k32 ;movlw 2 ;mode1-->mode2
;subwf mode,w
btfss mode,2 ;status,z
goto k33
bsf flag7,jcqq
;; bsf flag5,zhong
goto process_ok
k33 ;movlw 3 ;mode2-->mode3
;subwf mode,w
btfss mode,3 ;status,z
goto k4
;wu btfss flag2,x_on
; goto k34
bcf flag3,rf
goto process_ok
;k34 ;wu
; movlw 0
; movwf mode
; bcf flag3,rf
; bcf flag5,zhong
; bcf flag5,zhai
; bcf flag5,kuan
; goto process_ok
;--------------------------------
k4 ;wide
clrf fsr
btfsc flag2,auto
goto k5 ;(wu)
movlw 12h
subwf key_buffer,w
btfss status,z
goto k5
btfsc flag3,rzhx
goto process_ok
btfsc flag3,rfhx
goto process_ok
;(wu) bsf flag1,qd
;; movlw 1
;; subwf mode,w
btfsc mode,1 ;status,z
goto process_ok ;if rounie, K4 neglected
btfss flag3,rf
goto k4x
bsf flag3,rzhx
bcf flag3,rz
bcf flag3,rf
bsf flag7,jcqq1
goto k4y
k4x
bsf flag3,rz
bsf flag7,jcqq
k4y btfss flag5,kuan
goto k41
;; bcf flag5,zhai
bcf flag5,kuan
bsf flag5,zhong
goto process_ok
k41 btfss flag5,zhong
goto k42
;; bcf flag5,kuan
bsf flag5,zhai
bcf flag5,zhong
goto process_ok
k42 btfss flag5,zhai
goto process_ok
;; bcf flag5,zhong
bcf flag5,zhai
bsf flag5,kuan
goto process_ok
;------------------------------------
k5 ;shang xing
;; btfsc flag2,auto
;; goto k7 ;(wu)
;; movlw 0f
;; andwf flag4,w
;; btfsc status,z
;; goto k6 ;(wu)
movlw 22 ;not z1,z2,z3,qs
subwf key_buffer,w
btfss status,z
goto k6
clrf qujian
clrf flag4
clrf flag6
bcf flag2,z2_ds
bcf flag5,z2_dx
bcf flag2,auto ;wu
movlw 83h
andwf flag7,f ;wu
btfss flag3,xx
goto k51
bsf portb,0
bsf porta,3
bcf status,5
bsf status,6
call delay_fw
bcf flag3,xx
bsf flag3,sx
bcf status,6
goto auto_mode
k51
btfsc flag3,sx
goto process_ok
btfsc portb,3
goto process_ok
;(wu) bsf flag1,qd
bsf flag3,sx
goto process_ok
;-------------------------------------
k6 ;xia xing
;; btfsc flag2,auto
;; goto k7 ;(wu)
;; movlw 0f
;; andwf flag4,w
;; btfsc status,z
;; goto k7 ;(wu)
movlw 32h ;not z1,z2,z3,qs
subwf key_buffer,w
btfss status,z
goto k7
clrf qujian
clrf flag4
clrf flag6
bcf flag2,z2_ds
bcf flag5,z2_dx
bcf flag2,auto ;wu
movlw 83h
andwf flag7,f ;wu
;;(wu) bcf flag3,xx
;; bcf flag3,sx
btfss flag3,sx
goto k61
bsf portb,0
bsf porta,3
bcf status,5
bsf status,6
call delay_fw
bcf flag3,sx
bsf flag3,xx
;; bsf status,5
bcf status,6
goto auto_mode
k61
btfsc flag3,xx
goto process_ok
btfsc portb,4
goto process_ok
bsf flag1,qd
bsf flag3,xx
goto process_ok
;------------------------------------
k7 ;qu jian
movlw 14h
subwf key_buffer,w
btfss status,z
goto k8
bsf flag1,qd
bsf flag2,x_on
bcf flag2,auto ;wu
movlw 83h
andwf flag7,f ;wu
bcf flag4,qs
bsf fsr,4
bsf fsr,5
bcf fsr,6
clrf 31
clrf 34
clrf 36
movlw T500MS
movwf 30
movwf 33
movwf 35
clrf fsr
clrf flag4
bcf flag2,z2_ds
bcf flag5,z2_dx
clrf flag6
incf qujian,f
movlw 4
subwf qujian,w
btfss status,z
goto k71
movlw 1
movwf qujian
k71 movlw 1 ;z1
subwf qujian,w
btfss status,z
goto k72
bsf flag4,z1
goto k711
k72 movlw 2
subwf qujian,w
btfss status,z
goto k73
bsf flag4,z2
k711 btfss flag3,xx
goto k712
bcf flag3,xx
bcf flag3,sx
bsf flag3,xshx
goto process_ok
k712
btfsc portb,3
goto k713
bsf flag3,sx
goto process_ok
k713
bsf flag3,xx
btfss flag4,z1
goto k714
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -