⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 grass.asm

📁 一套实验系统的数字化改造程序
💻 ASM
📖 第 1 页 / 共 3 页
字号:
        ljmp  new_detect_circle


depth_reset:
        mov   a,60h
        orl   a,#00h
        jnz   bigzero

depth1_reset:
        call  motor1bonestep
        call  flashled2
        djnz  42h,depth1_reset
        mov   60h,#00
        mov   68h,#00
        mov   42h,#00
        call  display
        mov   70h,#00
        
        call  display70
        ljmp  waitfor_down

bigzero:
depth_number:
        mov   67h,#255
depth2_reset:
        call  motor1bonestep
        call  flashled2

        djnz  67h,depth2_reset
        djnz  60h,depth_number
        mov   60h,#00
        mov   42h,#00
        mov   70h,#00
        call  display
        call  display70
        ljmp  waitfor_down

depth_smalladd:
        call  motor1fonestep
        call  flashled1
        inc   42h
        inc   70h
        call  display
        call  display70
        ljmp  adjustk1

depth_smallsub:
        call  motor1bonestep
        call  flashled2
        dec   42h
        dec   70h
        call  display
        call  display70
        ljmp  adjustk1

depth_bigadd:
        call  motor1fonestep
        call  flashled1
        inc   42h
        inc   70h
        call  display
        call  display70
        call  motor1fonestep
        call  flashled1
        inc   42h
        inc   70h
        call  display
        call  display70
        ljmp  adjustk1

depth_bigsub:
        call  motor1bonestep
        call  flashled2
        dec   42h
        dec   70h
        call  display
        call  display70
        call  motor1bonestep
        call  flashled2
        dec   42h
        dec   70h
        call  display
        call  display70
        ljmp  adjustk1

depth_set_up:
        clr   down
        setb  up
        ljmp  adjustk1

depth_set_down:
        clr   up
        setb  down
        ljmp  adjustk1


new_detect_circle:
        jb  up,flag_ok
        jb  down,flag_ok
        ljmp  detect_adjust

flag_ok: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

new_detectk1_k:
        mov   36h,#0ffh
        jnb   down,callup
         call  motor1fonestep
         call  flashled1
         inc   42h
         inc   70h
        call  display
        call  display70
callup:  jnb   up,new_detectk1
       call  motor1bonestep
        call  flashled2
        dec   42h
        dec   70h
        call  display
        call  display70

new_detectk1: mov   r3,#0f7h
        mov   r1,#00h
new_detectl2: mov   a,r3
        mov   p1,a
        mov   a,p1
        mov   r4,a
        setb  c
        mov   r5,#04h
new_detectl3: rlc   a
        jnc   new_detectkeyin
        inc   r1
        djnz  r5,new_detectl3
        mov   a,r3
        setb  c
        rrc   a
        mov   r3,a
        jc    new_detectl2
        ljmp  new_detectk1_k

new_detectkeyin: mov   r7,#60
  new_detectd2:  mov   r6,#248
        djnz  r6,$
        djnz  r7,new_detectd2

  new_detectd3:  mov   a,p1
        xrl   a,r4
        jz    new_detectd3
        mov   a,r1
        mov   dptr,#table
        movc  a,@a+dptr

        mov   36h,a
        xrl   a,#00h        ;scan the 0(stop) key
        jnz   new_detectk1_k
        ljmp  new_detect_adjust

new_detect_adjust:
        mov   37h,#00h
new_adjustk1: mov   r3,#0f7h
        mov   r1,#00h
new_adjustl2: mov   a,r3
        mov   p1,a
        mov   a,p1
        mov   r4,a
        setb  c
        mov   r5,#04h
new_adjustl3: rlc   a
        jnc   new_adjustkeyin
        inc   r1
        djnz  r5,new_adjustl3
        mov   a,r3
        setb  c
        rrc   a
        mov   r3,a
        jc    new_adjustl2
        ljmp  new_adjustk1

new_adjustkeyin: mov   r7,#60
  new_adjustd2:  mov   r6,#248
        djnz  r6,$
        djnz  r7,new_adjustd2

  new_adjustd3:  mov   a,p1
        xrl   a,r4
        jz    new_adjustd3
        mov   a,r1
        mov   dptr,#table
        movc  a,@a+dptr
        mov   37h,a

        mov   a,37h
        xrl   a,#03h
        jnz   new_adjust_smallsub
        ljmp  new_depth_smalladd

new_adjust_smallsub:
        mov   a,37h
        xrl   a,#0ah
        jnz   new_adjust_bigadd
        ljmp  new_depth_smallsub

new_adjust_bigadd:
        mov   a,37h
        xrl   a,#01h
        jnz   new_adjust_bigsub
        ljmp  new_depth_bigadd

new_adjust_bigsub:
        mov   a,37h
        xrl   a,#02h
        jnz   new_adjust_reset
        ljmp  new_depth_bigsub

new_adjust_reset:
        mov   a,37h
        xrl   a,#0bh
        jnz   new_adjust_setup
        ljmp  new_depth_reset

new_adjust_setup:
        mov   a,37h
        xrl   a,#0fh
        jnz   new_adjust_setdown
        ljmp  new_depth_set_up

new_adjust_setdown:
        mov   a,37h
        xrl   a,#0dh
        jnz   new_adjust_start
        ljmp  new_depth_set_down

new_adjust_start:
        mov   a,37h
        xrl   a,#0eh
        jnz   new_adjustk1
        ljmp  new_detect_circle


new_depth_reset:
        mov   a,60h
        orl   a,#00h
        jnz   new_bigzero

new_depth1_reset:
        call  motor1bonestep
        call  flashled2
        djnz  42h,new_depth1_reset
        mov   60h,#00
        mov   42h,#00
        call  display
        mov    68h,#00
        mov    70h,#00
        call   display70

         ljmp  waitfor_down

new_bigzero:
new_depth_number:
        mov   67h,#255
new_depth2_reset:
        call  motor1bonestep
        call  flashled2

        djnz  67h,new_depth2_reset
        djnz  60h,new_depth_number
        mov   60h,#00
        mov   42h,#00
        mov   70h,#00
        call  display
        call  display70
        ljmp  waitfor_down

new_depth_smalladd:
        call  motor1fonestep
        call  flashled1
        inc   42h
        inc   70h
        call  display
        call  display70
        ljmp  new_adjustk1

new_depth_smallsub:
        call  motor1bonestep
        call  flashled2
        dec   42h
        dec   70h
        call  display
        call  display70
        ljmp  new_adjustk1

new_depth_bigadd:
        call  motor1fonestep
        call  flashled1
        inc   42h
        inc   70h
        call  display
        call  display70
        call  motor1fonestep
        call  flashled1
        inc   42h
        inc   70h
        call  display
        call  display70
        ljmp  new_adjustk1

new_depth_bigsub:
        call  motor1bonestep
        call  flashled2
        dec   42h
        dec   70h
        call  display
        call  display70
        call  motor1bonestep
        call  flashled2
        dec   42h
        dec   70h
        call  display
        call  display70
        ljmp  new_adjustk1

new_depth_set_up:
        clr   down
        setb  up
        ljmp  new_adjustk1

new_depth_set_down:
        clr   up
        setb  down
        ljmp  new_adjustk1

motor1bonestep:
        clr   p0.6
        cpl   p0.7
        call  delay1
        cpl   p0.7
        call  delay1
        ret

motor1fonestep:
        setb  p0.6
        cpl   p0.7
        call  delay1
        cpl   p0.7
        call  delay1
        ret

flashled1:
        clr  p0.4
        call  delay100ms
        setb p0.4
        call  delay100ms
        ret

flashled2:
        clr  p0.5
        call  delay100ms
        setb p0.5
        call  delay100ms
        ret

delay1:
       mov   r6,#160
    x1:mov   r7,#248
       djnz  r7,$
       djnz  r6,x1
       ret

delay10ms:
       mov   r6,#20
x10ms:mov   r7,#248
       djnz  r7,$
       djnz  r6,x10ms
       ret

delay100ms:
       mov   r6,#200
x100ms:mov   r7,#248
       djnz  r7,$
       djnz  r6,x100ms
       ret

delay500ms:
       mov   r6,#5
  d500:call  delay100ms
       djnz  r6,d500
       ret

delay1s:
       mov   r4,#10
 x1s:  call  delay100ms
       djnz  r4,x1s
       ret

CH451_INIT:	CLR   CH452_DIN
		SETB  CH452_DCLK
		SETB  CH452_DIN
		SETB  CH452_LOAD
                RET

CH452_WRITE:	CLR   EX0
		CLR   CH452_LOAD
                mov   a,41h
		MOV   R2,#08H

CH452_WRITE_8:
                RRC   a
		CLR   CH452_DCLK
		MOV   CH452_DIN,C
		SETB  CH452_DCLK
		DJNZ  R2,CH452_WRITE_8
		MOV   A,40h
		MOV   R2,#04H
CH452_WRITE_4:	RRC   A
		CLR   CH452_DCLK
		MOV   CH452_DIN,C
		SETB  CH452_DCLK
		DJNZ  R2,CH452_WRITE_4
		SETB  CH452_LOAD
		SETB  EX0
		RET


display:
     call  process60h

     mov   a,42h
     subb  a,#127
     jb   psw.7,ok
     ljmp  justbig127
ok:  clr   c
     mov   a,42h
     mov   b,#02
     mul   ab
     subb  a,#10
     jnb    psw.7,justbig10
     clr   c
     mov   a,42h
     mov   b,#02
     mul   ab
     mov   64h,a
     call  do_it
     ljmp  exit_display

justbig10:

     mov   a,42h
     mov   b,#02
     mul   ab
     subb  a,#100
     jnb   psw.7,justbig100
     clr   c
     mov   a,42h
     mov   b,#02
     mul   ab
     mov   b,#10
     div   ab

     add   a,63h
     mov   63h,a
     subb  a,#10
     jb    psw.7,iner1_small10
     mov   63h,a
     inc   62h
     ljmp  iner1_p62h

iner1_small10:
     mov   63h,63h
     ljmp  iner1_p62h

iner1_p62h:
     mov   a,62h
     subb  a,#10
     jb    psw.7,iner12_small10
     mov   a,62h
     subb  a,#10

     mov   62h,a
     inc   61h
     ljmp  iner1_p61h

iner12_small10:
     mov   62h,62h
     ljmp  iner1_p61h

iner1_p61h:
     mov   61h,61h
     mov   64h,b
     call  do_it

     ljmp  exit_display

justbig100:
     mov   a,42h
     mov   b,#02
     mul   ab

     mov   b,#10
     div   ab
     mov   64h,b

     mov   a,42h
     mov   b,#02
     mul   ab
     mov   b,#100

     div   ab
     mov   a,b
     mov   b,#10
     div   ab
     add   a,63h
     mov   63h,a
     subb  a,#10
     jb    psw.7,iner2_small10
     mov   63h,a
     inc   62h
     ljmp  iner2_p62h

iner2_small10:
     mov   63h,63h
     ljmp  iner2_p62h

iner2_p62h:
     mov   a,42h
     mov   b,#02
     mul   ab
     mov   b,#100
     div   ab
     add   a,62h
     mov   62h,a
     subb  a,#10
     jb    psw.7,iner22_small10
     mov   62h,a
     inc   61h
     ljmp  iner2_p61h

iner22_small10:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -