📄 频率计初步.asm
字号:
org 0000h
ajmp main
org 0003h
ajmp intx0
org 000bh
ajmp intt0
org 0100h
main:
mov sp,#5fh
setb it0
setb px0 ;外部中断0优先
mov tmod,#02h
xiayi:mov th0,#38h
mov tl0,#38h
SETB EA
SETB ET0
SETB EX0 ; 外中断
setb tr0
mov r7,#72
mov r6,#00h
wait: acall display
cjne r7,#00h,wait
mov ie,#00h ;只显示一秒到时的所测频率
clr tr0
mov r1,#30h; (30h)送到40单元
mov r0,#40h
zaici:mov b,@r1
mov @r0,b
inc r0
inc r1
cjne r1,#38h,zaici
mov r0,#30h
fanh: mov @r0,#00h ;将显示寄存器地址内容清零
inc r0
cjne r0,#38h,fanh
ajmp xiayi
display:
MOV R0,#40H
MOV 50H,#0BFH
DIS2:
MOV A,@R0
ACALL TABLE
MOV P2,A
MOV P0,50H
ACALL DELAY
MOV P0,#0FFH
INC R0
MOV A,50H
RR A
MOV 50H,A
CJNE R0,#44H,DIS2
RET
intx0: ;外中段
push psw
push acc
clr ex0 ;禁止外中断
mov r1,#30h
cmp: cjne @r1,#09h,first
mov @r1,#00h
inc r1
cjne r1,#38h,cmp
ajmp wanbi
first:inc @r1
wanbi:setb ex0
pop acc
pop psw
reti
intt0: ;定时器0中断
push psw
push acc
inc r6
cjne r6,#64,huiqu
mov r6,#00h
dec r7
huiqu:
pop acc
pop psw
reti
delay:
mov r5,#10h
delay0:mov r4,#40h
delay1:djnz r4,delay1
djnz r5,delay0
ret
table:
inc a
movc a,@a+pc
ret
db 0c0h,0f9h,0a4h,0b0h,099h,092h,082h,0f8h,80h,090h
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -