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

📄 bike.asm

📁 通过霍尔传感器测量车轮转动的次数
💻 ASM
📖 第 1 页 / 共 5 页
字号:
                lcall   yuchuli
                mov     3ch,52h
                mov     3dh,53h
                mov     3eh,54h
                mov     r0,#3ch
                lcall   btof

                mov     39h,#05h   ;最高位乘于65630,结果指向3ch
                mov     3ah,#65h
                mov     3bh,#53h
                mov     r0,#39h
                lcall   btof
                mov     r0,#3ch
                mov     r1,#39h
                lcall   fmul

                mov     r0,#3ch    ;前面的结果加上最高位,算出总共的圈数,结果指向36h
                mov     r1,#36h
                lcall   fadd

                mov     30h,#01h   ;轮圈的周长数据,指向30h
                mov     31h,#20h
                mov     32h,#90h
                mov     r0,#30h
                lcall   btof

                mov     r0,#3ch   ;轮圈的周长乘于总圈数,算出总共的行驶距离,结果指向3ch
                mov     r1,#30h
                lcall   fmul

                lcall   ftob

                mov     a,3ch
                subb    a,#04h
                jc      shangci_xiaoyu_1km
                ljmp    shangci_dayu_1km

shangci_xiaoyu_1km:
                clr     c
                mov     a,3ch
                cjne    a,#03h,shangci_xiaoyu100m

                call    qing_wei     ;后四个字位置清除

                MOV	A,#84H
		LCALL	SEND_I
                mov     a,3dh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3dh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#85H
		LCALL	SEND_I
                mov     a,3eh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#86H
		LCALL	SEND_I
                mov     a,#0c3h
                LCALL	SEND_D
                mov     a,#0d7h
                LCALL	SEND_D
                ljmp    out_shangci_lucheng_jisuan

  shangci_xiaoyu100m:
                call    qing_wei     ;后四个字位置清除

                mov     a,3ch
                cjne    a,#02h,shangci_xiaoyu10m
                MOV	A,#84H
		LCALL	SEND_I
                mov     a,3dh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3dh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#85H     ;米
		LCALL	SEND_I
                mov     a,#0c3h
                LCALL	SEND_D
                mov     a,#0d7h
                LCALL	SEND_D
                ljmp    out_shangci_lucheng_jisuan

  shangci_xiaoyu10m:
                call    qing_wei     ;后四个字位置清除

                MOV	A,#84H
		LCALL	SEND_I
                mov     a,3dh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D


                MOV	A,#85H     ;米
		LCALL	SEND_I
                mov     a,#0c3h
                LCALL	SEND_D
                mov     a,#0d7h
                LCALL	SEND_D

                ljmp    out_shangci_lucheng_jisuan

shangci_dayu_1km:
                mov     a,3ch
                cjne    a,#04h,shangci_dayu_10Km

                MOV	A,#84H
		LCALL	SEND_I
                mov     a,3dh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3dh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#85H
		LCALL	SEND_I
                mov     a,3eh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3eh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#86H     ;米
		LCALL	SEND_I
                mov     a,#0c3h
                LCALL	SEND_D
                mov     a,#0d7h
                LCALL	SEND_D

                MOV	A,#87H     ;显示空白
		LCALL	SEND_I
                mov     a,#0a1h
                LCALL	SEND_D
                mov     a,#0a0h
                LCALL	SEND_D

                jmp     out_shangci_lucheng_jisuan

   shangci_dayu_10Km:
                call    qing_wei     ;后四个字位置清除

                MOV	A,#84H
		LCALL	SEND_I
                mov     a,3dh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3dh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#85H
		LCALL	SEND_I
                mov     a,#2eh
                LCALL	SEND_D


                MOV	A,#86H
		LCALL	SEND_I
                mov     a,3eh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3eh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#87H    ;Km
		LCALL	SEND_I
                mov     a,#4bh
                LCALL	SEND_D
                mov     a,#6dh
                LCALL	SEND_D
out_shangci_lucheng_jisuan:
                ret

;以轮子一圈周长一米计算,43h 44h 45h全部溢出的里程数为16711Km,因此以9999Km为一个清除周期
jisuan_zonglicheng:
                mov     50h,43h     ;预处理最低位圈数40h,结果指向30h
                call    yuchuli
                mov     30h,52h
                mov     31h,53h
                mov     32h,54h
                mov     r0,#30h
                lcall   btof

                mov     50h,44h    ;预处理中间位圈数41h,结果指向36h
                call    yuchuli
                mov     36h,52h
                mov     37h,53h
                mov     38h,54h
                mov     r0,#36h
                lcall   btof

                mov     33h,#03h   ;中间位乘于255,结果指向36h
                mov     34h,#25h
                mov     35h,#60h
                mov     r0,#33h
                lcall   btof
                mov     r0,#36h
                mov     r1,#33h
                lcall   fmul

                mov     r1,#30h  ;中间位加上最低位的圈数,结果指向36h
                lcall   fadd

                mov     50h,45h   ;预处理最高位圈数42h,结果指向3ch
                lcall   yuchuli
                mov     3ch,52h
                mov     3dh,53h
                mov     3eh,54h
                mov     r0,#3ch
                lcall   btof

                mov     39h,#05h   ;最高位乘于65630,结果指向3ch
                mov     3ah,#65h
                mov     3bh,#53h
                mov     r0,#39h
                lcall   btof
                mov     r0,#3ch
                mov     r1,#39h
                lcall   fmul

                mov     r0,#3ch    ;前面的结果加上最高位,算出总共的圈数,结果指向36h
                mov     r1,#36h
                lcall   fadd

                mov     30h,#01h   ;轮圈的周长数据,指向30h
                mov     31h,#20h
                mov     32h,#90h
                mov     r0,#30h
                lcall   btof

                mov     r0,#3ch   ;轮圈的周长乘于总圈数,算出总共的行驶距离,结果指向3ch
                mov     r1,#30h
                lcall   fmul

                lcall   ftob


                MOV	A,#93H
		LCALL	SEND_I
                mov     a,#0a1h
                LCALL	SEND_D
                mov     a,#0a0h
                LCALL	SEND_D

                mov     a,3ch
                subb    a,#04h
                jc      zong_xiaoyu_1km
                ljmp    zong_dayu_1km

zong_xiaoyu_1km:
                clr     c
                mov     a,3ch
                cjne    a,#03h,zong_xiaoyu100m

                call    qing_wei     ;后四个字位置清除

                MOV	A,#94H
		LCALL	SEND_I
                mov     a,3dh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3dh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#95H
		LCALL	SEND_I
                mov     a,3eh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#96H
		LCALL	SEND_I
                mov     a,#0c3h
                LCALL	SEND_D
                mov     a,#0d7h
                LCALL	SEND_D
                ljmp    out_zong_lucheng_jisuan

zong_xiaoyu100m:
                call    qing_wei     ;后四个字位置清除

                mov     a,3ch
                cjne    a,#02h,zong_xiaoyu10m
                MOV	A,#94H
		LCALL	SEND_I
                mov     a,3dh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3dh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#95H     ;米
		LCALL	SEND_I
                mov     a,#0c3h
                LCALL	SEND_D
                mov     a,#0d7h
                LCALL	SEND_D
                ljmp    out_zong_lucheng_jisuan

  zong_xiaoyu10m:
                call    qing_wei     ;后四个字位置清除

                MOV	A,#94H
		LCALL	SEND_I
                mov     a,3dh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D


                MOV	A,#95H     ;米
		LCALL	SEND_I
                mov     a,#0c3h
                LCALL	SEND_D
                mov     a,#0d7h
                LCALL	SEND_D

                ljmp    out_zong_lucheng_jisuan

zong_dayu_1km:  mov     a,3ch
                cjne    a,#04h,zong_dayu_10Km

                MOV	A,#94H
		LCALL	SEND_I
                mov     a,3dh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3dh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#95H
		LCALL	SEND_I
                mov     a,3eh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3eh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#96H     ;米
		LCALL	SEND_I
                mov     a,#0c3h
                LCALL	SEND_D
                mov     a,#0d7h
                LCALL	SEND_D

                MOV	A,#97H
		LCALL	SEND_I
                mov     a,#0a1h
                LCALL	SEND_D
                mov     a,#0a0h
                LCALL	SEND_D

                jmp     out_zong_lucheng_jisuan

zong_dayu_10Km: mov     a,3ch
                cjne    a,#05h,zong_dayu_100Km
                MOV	A,#94H
		LCALL	SEND_I

                mov     a,3dh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3dh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#95H
		LCALL	SEND_I
                mov     a,#2eh
                LCALL	SEND_D


                MOV	A,#96H
		LCALL	SEND_I
                mov     a,3eh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3eh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#97H    ;Km
		LCALL	SEND_I
                mov     a,#4bh
                LCALL	SEND_D
                mov     a,#6dh
                LCALL	SEND_D
                jmp     out_zong_lucheng_jisuan

zong_dayu_100Km:mov     a,3ch
                cjne    a,#06h,zong_dayu_1000Km
                MOV	A,#94H
		LCALL	SEND_I

                mov     a,3dh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3dh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                MOV	A,#95H
		LCALL	SEND_I
                mov     a,3eh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

                mov     a,#2eh   ;小数点
                LCALL	SEND_D

                MOV	A,#96H
		LCALL	SEND_I
                mov     a,3eh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,#20h    ;ASCII中的空白字符
                LCALL	SEND_D

                MOV	A,#97H    ;Km
		LCALL	SEND_I
                mov     a,#4bh
                LCALL	SEND_D
                mov     a,#6dh
                LCALL	SEND_D
                jmp     out_zong_lucheng_jisuan

zong_dayu_1000Km:
                MOV	A,#94H
		LCALL	SEND_I
                mov     a,3dh
                swap    a
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D
                mov     a,3dh
                anl     a,#0fh
                add     a,#30h
                LCALL	SEND_D

⌨️ 快捷键说明

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