📄 grass.asm
字号:
FLAG DATA 20H
FLAG1 DATA 21H
PFA BIT FLAG.7
PFB BIT FLAG.6
PFC BIT FLAG.5
PFD BIT FLAG.4
READY BIT FLAG.3
up BIT FLAG.2
down BIT FLAG.1
zero2 bit FLAG.0
READY1 BIT FLAG1.7
fu bit FLAG1.6
CH452_DCLK BIT P0.2
CH452_DIN BIT P0.1
CH452_LOAD BIT P0.0
mov 60h,#00
mov 61h,#00
mov 62h,#00
mov 63h,#00
mov 64h,#00
mov 68h,#00
call CH451_INIT
MOV 40h,#04H
MOV 41h,#01H
CALL CH452_WRITE
MOV 40h,#05H
MOV 41h,#80H
CALL CH452_WRITE
cw bit p0.6
clk bit p0.7
mov 20h,#00h
mov 21h,#00h
mov 42h,#254h
mov r1,#08h
mov 40h,#08h
clear:
mov 41h,#00h
LCALL CH452_WRITE
inc 40h
djnz r1,clear
first_zero_cirlce:
fk1: mov r3,#0f7h
mov r1,#00h
fl2: mov a,r3
mov p1,a
mov a,p1
mov r4,a
setb c
mov r5,#04h
fl3: rlc a
jnc fkeyin
inc r1
djnz r5,fl3
mov a,r3
setb c
rrc a
mov r3,a
jc fl2
ljmp fk1
fkeyin: mov r7,#60
fd2: mov r6,#248
djnz r6,$
djnz r7,fd2
fd3: mov a,p1
xrl a,r4
jz fd3
mov a,r1
mov dptr,#table
movc a,@a+dptr
mov 30h,a
xrl a,#04h
jnz first_zero_smalladd
ljmp set_first_zero_flag
first_zero_smalladd:
mov a,30h
xrl a,#03h
jnz first_zero_smallsub
ljmp z1smalladd
first_zero_smallsub:
mov a,30h
xrl a,#0ah
jnz first_zero_bigadd
ljmp z1smallsub
first_zero_bigadd:
mov a,30h
xrl a,#01h
jnz first_zero_bigsub
ljmp z1bigadd
first_zero_bigsub:
mov a,30h
xrl a,#02h
jnz endtest_zero_circle
ljmp z1bigsub
endtest_zero_circle:
ljmp fk1
set_first_zero_flag:
setb READY
clr p0.3
ljmp test_first_zero_flag
z1smalladd:
call motor1fonestep
call flashled1
ljmp test_first_zero_flag
z1smallsub:
call motor1bonestep
call flashled2
ljmp test_first_zero_flag
z1bigadd:
call motor1fonestep
call flashled1
call motor1fonestep
call flashled1
ljmp test_first_zero_flag
z1bigsub:
call motor1bonestep
call flashled2
call motor1bonestep
call flashled2
ljmp test_first_zero_flag
test_first_zero_flag:
jb READY,waitfor_down
ljmp fk1
waitfor_down:
clr UP
clr DOWN
mov 42h,#00h
mov 43h,#00h
mov 35h,#00h
clr p0.3
waitfork1: mov r3,#0f7h
mov r1,#00h
waitforl2: mov a,r3
mov p1,a
mov a,p1
mov r4,a
setb c
mov r5,#04h
waitforl3: rlc a
jnc waitforkeyin
inc r1
djnz r5,waitforl3
mov a,r3
setb c
rrc a
mov r3,a
jc waitforl2
ljmp waitfork1
waitforkeyin: mov r7,#60
waitford2: mov r6,#248
djnz r6,$
djnz r7,waitford2
waitford3: mov a,p1
xrl a,r4
jz waitford3
mov a,r1
mov dptr,#table
movc a,@a+dptr
mov 35h,a
xrl a,#0eh
jnz waitfork1
ljmp second_zero_circle
second_zero_circle:
mov 31h,#0ffh
z2k1_k:
call motor1fonestep
call flashled1
inc 42h
call display
call delay100ms
z2k1: mov r3,#0f7h
mov r1,#00h
z2l2: mov a,r3
mov p1,a
mov a,p1
mov r4,a
setb c
mov r5,#04h
z2l3: rlc a
jnc z2keyin
inc r1
djnz r5,z2l3
mov a,r3
setb c
rrc a
mov r3,a
jc z2l2
ljmp z2k1_k
z2keyin: mov r7,#60
z2d2: mov r6,#248
djnz r6,$
djnz r7,z2d2
z2d3: mov a,p1
xrl a,r4
jz z2d3
mov a,r1
mov dptr,#table
movc a,@a+dptr
mov 31h,a
xrl a,#00h
jnz z2k1_k
ljmp zero2_adjust
zero2_adjust:
clr READY1
mov 32h,#00h
z2adk1: mov r3,#0f7h
mov r1,#00h
z2adl2: mov a,r3
mov p1,a
mov a,p1
mov r4,a
setb c
mov r5,#04h
z2adl3: rlc a
jnc z2adkeyin
inc r1
djnz r5,z2adl3
mov a,r3
setb c
rrc a
mov r3,a
jc z2adl2
ljmp z2adk1
z2adkeyin: mov r7,#60
z2add2: mov r6,#248
djnz r6,$
djnz r7,z2add2
z2add3: mov a,p1
xrl a,r4
jz z2add3
mov a,r1
mov dptr,#table
movc a,@a+dptr
mov 32h,a
xrl a,#05h
jnz second_zero_smalladd
ljmp set_second_zero_flag
second_zero_smalladd:
mov a,32h
xrl a,#03h
jnz second_zero_smallsub
ljmp z2smalladd
second_zero_smallsub:
mov a,32h
xrl a,#0ah
jnz second_zero_bigadd
ljmp z2smallsub
second_zero_bigadd:
mov a,32h
xrl a,#01h
jnz second_zero_bigsub
ljmp z2bigadd
second_zero_bigsub:
mov a,32h
xrl a,#02h
jnz endtest_zero2_circle
ljmp z2bigsub
endtest_zero2_circle:
ljmp z2adk1
set_second_zero_flag:
setb READY1
ljmp test_second_zero_flag
z2smalladd:
call motor1fonestep
call flashled1
inc 42h
call display
ljmp test_second_zero_flag
z2smallsub:
call motor1bonestep
call flashled2
dec 42h
call display
ljmp test_second_zero_flag
z2bigadd:
call motor1fonestep
call flashled1
inc 42h
call display
call motor1fonestep
call flashled1
inc 42h
call display
ljmp test_second_zero_flag
z2bigsub:
call motor1bonestep
call flashled2
dec 42h
call display
call motor1bonestep
call flashled2
dec 42h
call display
ljmp test_second_zero_flag
test_second_zero_flag:
jb READY1,raiseup_circle
ljmp zero2_adjust
raiseup_circle:
mov 70h,#00
mov 69h,#5
raiseup_go_on:
call motor1bonestep
call flashled2
call delay10ms
dec 42h
call display
mov a,70h
subb a,#01
mov 70h,a
; call display70
djnz 69h,raiseup_go_on
setb fu
waitfor_detect:
mov 38h,#00h
clr p0.3
waitfordk1: mov r3,#0f7h
mov r1,#00h
waitfordl2: mov a,r3
mov p1,a
mov a,p1
mov r4,a
setb c
mov r5,#04h
waitfordl3: rlc a
jnc waitfordkeyin
inc r1
djnz r5,waitfordl3
mov a,r3
setb c
rrc a
mov r3,a
jc waitfordl2
ljmp waitfordk1
waitfordkeyin: mov r7,#60
waitfordd2: mov r6,#248
djnz r6,$
djnz r7,waitfordd2
waitfordd3: mov a,p1
xrl a,r4
jz waitfordd3
mov a,r1
mov dptr,#table
movc a,@a+dptr
mov 38h,a
xrl a,#0eh
jnz waitfordk1
ljmp detect_circle
detect_circle:
mov 33h,#0ffh
clr p3.7
clr p3.0
setb p3.1
mov a,p2
cpl a
mov 65h,a ;read number
setb p3.0
mov a,#0ffh
mov p2,a
clr p3.1
mov a,p2
cpl a
mov 66h,a ;read gap
detectk1_k:
call motor1fonestep
call flashled1
inc 42h
call display
mov a,70h
addc a,#01
mov 70h,a
orl a,#00
jz set_70flag
jb fu,detectk1
set_70flag:
clr fu
call display70
detectk1: mov r3,#0f7h
mov r1,#00h
detectl2: mov a,r3
mov p1,a
mov a,p1
mov r4,a
setb c
mov r5,#04h
detectl3: rlc a
jnc detectkeyin
inc r1
djnz r5,detectl3
mov a,r3
setb c
rrc a
mov r3,a
jc detectl2
ljmp detectk1_k
detectkeyin: mov r7,#60
detectd2: mov r6,#248
djnz r6,$
djnz r7,detectd2
detectd3: mov a,p1
xrl a,r4
jz detectd3
mov a,r1
mov dptr,#table
movc a,@a+dptr
mov 33h,a
xrl a,#00h ;scan the 0(stop) key
jnz detectk1_k
ljmp detect_adjust
detect_adjust:
mov 34h,#00h
adjustk1: mov r3,#0f7h
mov r1,#00h
adjustl2: mov a,r3
mov p1,a
mov a,p1
mov r4,a
setb c
mov r5,#04h
adjustl3: rlc a
jnc adjustkeyin
inc r1
djnz r5,adjustl3
mov a,r3
setb c
rrc a
mov r3,a
jc adjustl2
ljmp adjustk1
adjustkeyin: mov r7,#60
adjustd2: mov r6,#248
djnz r6,$
djnz r7,adjustd2
adjustd3: mov a,p1
xrl a,r4
jz adjustd3
mov a,r1
mov dptr,#table
movc a,@a+dptr
mov 34h,a
mov a,34h
xrl a,#03h
jnz adjust_smallsub
ljmp depth_smalladd
adjust_smallsub:
mov a,34h
xrl a,#0ah
jnz adjust_bigadd
ljmp depth_smallsub
adjust_bigadd:
mov a,34h
xrl a,#01h
jnz adjust_bigsub
ljmp depth_bigadd
adjust_bigsub:
mov a,34h
xrl a,#02h
jnz adjust_reset
ljmp depth_bigsub
adjust_reset:
mov a,34h
xrl a,#0bh
jnz adjust_setup
ljmp depth_reset
adjust_setup:
mov a,34h
xrl a,#0fh
jnz adjust_setdown
ljmp depth_set_up
adjust_setdown:
mov a,34h
xrl a,#0dh
jnz adjust_start
ljmp depth_set_down
adjust_start:
mov a,34h
xrl a,#0eh
jnz adjustk1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -