微机原理频率测试仪
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
MOV AH,09H
INT 21H
MOV CX,B_H2;显示时
MOV AL,CL
MOVAH,0
CALLXS
LEA DX,S4
MOV AH,09H
INT 21H
MOV DX,B_H;显示分
MOV AL,DH
MOVAH,0
CALLXS;显示秒
RET
RQENDP
CSHPROC;8253初始化子程序
LEA DX,S10
B_HDW?;开辟存储器空间,保护数据
B_H2DW?
PORT8253EQU240BH;8253控制寄存器地址
PORT8255EQU2403H;8255控制寄存器地址
PORT0EQU2408H;8253 0通道的地址
PORT1EQU2409H
PORT2EQU240AH
PORTAEQU2400H;8255A口的地址
INT21H;从键盘接收一个字符
CALLPD
CMPAL,1;判断是否继续测量
JNEEXIT
JMPKS
EXIT:MOV AH,4CH;返回DOS
INT21H
XSPROC;显示4位数的子程序
MOV BX,AX
CMP AX,1000;判断AX的值是否小于1000,小于则跳到百位
JBBAI
MOV CX,1000
S10DB0,0,0,0,'Waiting 6s...','$'
S11DB'********************************************************************************','$'
S12DB0DH,0AH,0AH,'Press any key to continue !','$'
CALLSJ;显示欢迎界面及开发者
MOV DX,PORT8255
MOV AL,10010000B;初始化8255,A口0方式输入
KS:CALLCSH;8253的初始化程序
J_C:MOV DX,PORTA
IN AL,DX
TEST AL,1
JZ J_C;检测6s时间是否到,没到则持续检测PA0,PA0与OUT2连接
INT 21H;显示百位
SHI: CMP AX,10
JBG_E
MOV AX,BX
MOV CX,10
MOV DX,0
DIV CX
MOV BX,DX
ADD AL,30H
MOV DL,AL
MOV AH,02H
INT 21H;显示十位
G_E:MOVDX,BX
ADDDL,30H
MOVAH,02H
INT21H;显示个位
MOV AX,6000
OUT DX,AL
MOV AL,AH
OUT DX,AL;初始化2#通道,方式0,用于6s定时
RET
CSHENDP
PDPROC;判断子程序,判断输入是否正确
HL:CMPAL,'y'
JEOK
CMPAL,'n'
JENOK
LEADX,S8
MOVAH,09H
INT21H;显示S8
LEADX,S6
MOV CX,6
DIV CX;频率值存入AX中
MOV B_H,AX
LEA DX,S1
MOV AH,09H
INT 21H;显示S1
MOV AX,B_H
CALL XS;调用XS子程序,将AX中的值显示出来
LEA DX,S2
MOV AH,09H
INT 21H;显示S2
CALL RQ;调用RQ子程序,显示当前的日期时间
MOV AH,09H
INT 21H;显示S10
MOV DX,PORT8253
MOV AL,00110000B
OUT DX,AL
MOV DX,PORT0
MOV AX,60000
OUT DX,AL
MOV AL,AH
OUT DX,AL;初始化0#通道,方式0,用于测量脉冲数
MOV DX,PORT8253
MOV AL,01110110B
JMP GO
CW:LEA DX,S1;显示错误ERROR
MOV AH,09H
INT 21H;显示S1
LEA DX,S7
MOVAH,09H
INT21H;显示S7
LEA DX,S2
MOV AH,09H
INT 21H;显示S2
CALL RQ
GO:LEA DX,S6
MOVAH,09H
INT21H;显示S6
MOV AH,01H
OUT DX,AL
MOV DX,PORT1
MOV AX,1000
OUT DX,AL
MOV AL,AH
OUT DX,AL;初始化1#通道,方式3,用于将1MHZ分频为1KHZ,1MHZ/1000=1KHZ
MOV DX,PORT8253
MOV AL,10110000B
OUT DX,AL
MOV DX,PORT2
源程序:
DATASEGMENT
S1DB0DH,0AH,0AH,'f = ','$'
s2DB'Hz',0,0,0,0,'TIME:','$'
s3DB'/','$'
s4DB':','$'
S5DB0,0,0,0,'$'
S6DB0,0,0,'go on ?(y/n)','$'
S7DB'ERROR! ','$'
MOVAH,09H
INT21H;显示S6
MOVAH,01H
INT21H;从键盘接收一个字符
JMPHL
OK: MOVAL,1;输入正确,返回1到AL
RET
NOK:MOVAL,0
RET
PDEБайду номын сангаасDP
SJPROC;菜单子程序
LEA DX,S11
MOV AH,09H
INT 21H;显示S11
LEA DX,S9
JBCW
CMPAX,60000
JACW
MOV DX,PORTA;PA7与OUT0相接,检测OUT0是否输出高电平
IN AL,DX
TESTAL,80H
JNZCW;判断是否超出量程
MOV AX,B_H;从存储器中将AX读出来
MOV BX,60000
SUB BX,AX
MOV AX,BX
MOV DX,0;扩展位数,AX扩展到DX:AX
MOV AH,09H
INT 21H;显示S9
LEA DX,S11
MOV AH,09H
INT 21H;显示S11
LEA DX,S12
MOV AH,09H
INT 21H;显示S12
MOV AH,08H
INT21H;从键盘接收一个字符
RET
ENDP
CODEENDS
ENDSTART
DATAENDS
STAKSEGMENT
DB100DUP(?)
TOPDB?
STAKENDS
CODESEGMENT
ASSUMECS:CODE,DS:DATA,SS:STAK
START:MOV AX,DATA
MOV DS,AX
MOV AX,STAK
MOV SS,AX
MOV SP,OFFSET TOP;初始化堆栈段指针寄存器
MOV DX,0
DIV CX
MOV BX,DX
ADD AL,30H
MOV DL,AL
MOV AH,02H
INT 21H;显示千位
BAI:CMP AX,100
JBSHI
MOV AX,BX
MOV CX,100
MOV DX,0
DIV CX
MOV BX,DX
ADD AL,30H
MOV DL,AL
MOV AH,02H
MOV AH,09H
INT 21H
MOV DX,B_H;显示月
MOV AL,DL
MOVAH,0
CALL XS;显示日
LEA DX,S5
MOV AH,09H
INT 21H
MOVAH,2CH
INT21H
MOV B_H,DX
MOV B_H2,CX;获取时间
MOV AL,CH
MOVAH,0
CALLXS
LEA DX,S4
MOV DX,PORT8253
MOV AL,0
OUT DX,AL;6s时间到,将0通道的计数值所存在锁存器中
MOV DX,PORT0
IN AL,DX
MOV BL,AL
IN AL,DX
MOV AH,AL
MOV AL,BL;将锁存器中的值读入AX中,先低后高
MOVB_H,AX;保护AX,存入存储器中
CMPAX,6
RET
XSENDP
RQPROC;日期显示子程序
MOV AH,2AH
INT 21H;取日期到CX,DX
MOV B_H,DX
MOV AX,CX
CALL XS
LEA DX,S3
MOV AH,09H
INT 21H
MOV DX,B_H
MOV B_H,DX;显示年
MOV AL,DH
MOVAH,0
CALL XS
LEA DX,S3
S8DB0DH,0AH,0AH,'Please input right choice y or n !','$'
S9DB0DH,0AH,0,0,0,0,0,0,0,0,0,0,'Welcome to this system(measuring range :0-9999Hz) !',0DH,0AH,0AH,0,0,0,0,0,0,0,0,0,0,'Designer:XXX',0DH,0AH,0AH,'$'
INT 21H
MOV CX,B_H2;显示时
MOV AL,CL
MOVAH,0
CALLXS
LEA DX,S4
MOV AH,09H
INT 21H
MOV DX,B_H;显示分
MOV AL,DH
MOVAH,0
CALLXS;显示秒
RET
RQENDP
CSHPROC;8253初始化子程序
LEA DX,S10
B_HDW?;开辟存储器空间,保护数据
B_H2DW?
PORT8253EQU240BH;8253控制寄存器地址
PORT8255EQU2403H;8255控制寄存器地址
PORT0EQU2408H;8253 0通道的地址
PORT1EQU2409H
PORT2EQU240AH
PORTAEQU2400H;8255A口的地址
INT21H;从键盘接收一个字符
CALLPD
CMPAL,1;判断是否继续测量
JNEEXIT
JMPKS
EXIT:MOV AH,4CH;返回DOS
INT21H
XSPROC;显示4位数的子程序
MOV BX,AX
CMP AX,1000;判断AX的值是否小于1000,小于则跳到百位
JBBAI
MOV CX,1000
S10DB0,0,0,0,'Waiting 6s...','$'
S11DB'********************************************************************************','$'
S12DB0DH,0AH,0AH,'Press any key to continue !','$'
CALLSJ;显示欢迎界面及开发者
MOV DX,PORT8255
MOV AL,10010000B;初始化8255,A口0方式输入
KS:CALLCSH;8253的初始化程序
J_C:MOV DX,PORTA
IN AL,DX
TEST AL,1
JZ J_C;检测6s时间是否到,没到则持续检测PA0,PA0与OUT2连接
INT 21H;显示百位
SHI: CMP AX,10
JBG_E
MOV AX,BX
MOV CX,10
MOV DX,0
DIV CX
MOV BX,DX
ADD AL,30H
MOV DL,AL
MOV AH,02H
INT 21H;显示十位
G_E:MOVDX,BX
ADDDL,30H
MOVAH,02H
INT21H;显示个位
MOV AX,6000
OUT DX,AL
MOV AL,AH
OUT DX,AL;初始化2#通道,方式0,用于6s定时
RET
CSHENDP
PDPROC;判断子程序,判断输入是否正确
HL:CMPAL,'y'
JEOK
CMPAL,'n'
JENOK
LEADX,S8
MOVAH,09H
INT21H;显示S8
LEADX,S6
MOV CX,6
DIV CX;频率值存入AX中
MOV B_H,AX
LEA DX,S1
MOV AH,09H
INT 21H;显示S1
MOV AX,B_H
CALL XS;调用XS子程序,将AX中的值显示出来
LEA DX,S2
MOV AH,09H
INT 21H;显示S2
CALL RQ;调用RQ子程序,显示当前的日期时间
MOV AH,09H
INT 21H;显示S10
MOV DX,PORT8253
MOV AL,00110000B
OUT DX,AL
MOV DX,PORT0
MOV AX,60000
OUT DX,AL
MOV AL,AH
OUT DX,AL;初始化0#通道,方式0,用于测量脉冲数
MOV DX,PORT8253
MOV AL,01110110B
JMP GO
CW:LEA DX,S1;显示错误ERROR
MOV AH,09H
INT 21H;显示S1
LEA DX,S7
MOVAH,09H
INT21H;显示S7
LEA DX,S2
MOV AH,09H
INT 21H;显示S2
CALL RQ
GO:LEA DX,S6
MOVAH,09H
INT21H;显示S6
MOV AH,01H
OUT DX,AL
MOV DX,PORT1
MOV AX,1000
OUT DX,AL
MOV AL,AH
OUT DX,AL;初始化1#通道,方式3,用于将1MHZ分频为1KHZ,1MHZ/1000=1KHZ
MOV DX,PORT8253
MOV AL,10110000B
OUT DX,AL
MOV DX,PORT2
源程序:
DATASEGMENT
S1DB0DH,0AH,0AH,'f = ','$'
s2DB'Hz',0,0,0,0,'TIME:','$'
s3DB'/','$'
s4DB':','$'
S5DB0,0,0,0,'$'
S6DB0,0,0,'go on ?(y/n)','$'
S7DB'ERROR! ','$'
MOVAH,09H
INT21H;显示S6
MOVAH,01H
INT21H;从键盘接收一个字符
JMPHL
OK: MOVAL,1;输入正确,返回1到AL
RET
NOK:MOVAL,0
RET
PDEБайду номын сангаасDP
SJPROC;菜单子程序
LEA DX,S11
MOV AH,09H
INT 21H;显示S11
LEA DX,S9
JBCW
CMPAX,60000
JACW
MOV DX,PORTA;PA7与OUT0相接,检测OUT0是否输出高电平
IN AL,DX
TESTAL,80H
JNZCW;判断是否超出量程
MOV AX,B_H;从存储器中将AX读出来
MOV BX,60000
SUB BX,AX
MOV AX,BX
MOV DX,0;扩展位数,AX扩展到DX:AX
MOV AH,09H
INT 21H;显示S9
LEA DX,S11
MOV AH,09H
INT 21H;显示S11
LEA DX,S12
MOV AH,09H
INT 21H;显示S12
MOV AH,08H
INT21H;从键盘接收一个字符
RET
ENDP
CODEENDS
ENDSTART
DATAENDS
STAKSEGMENT
DB100DUP(?)
TOPDB?
STAKENDS
CODESEGMENT
ASSUMECS:CODE,DS:DATA,SS:STAK
START:MOV AX,DATA
MOV DS,AX
MOV AX,STAK
MOV SS,AX
MOV SP,OFFSET TOP;初始化堆栈段指针寄存器
MOV DX,0
DIV CX
MOV BX,DX
ADD AL,30H
MOV DL,AL
MOV AH,02H
INT 21H;显示千位
BAI:CMP AX,100
JBSHI
MOV AX,BX
MOV CX,100
MOV DX,0
DIV CX
MOV BX,DX
ADD AL,30H
MOV DL,AL
MOV AH,02H
MOV AH,09H
INT 21H
MOV DX,B_H;显示月
MOV AL,DL
MOVAH,0
CALL XS;显示日
LEA DX,S5
MOV AH,09H
INT 21H
MOVAH,2CH
INT21H
MOV B_H,DX
MOV B_H2,CX;获取时间
MOV AL,CH
MOVAH,0
CALLXS
LEA DX,S4
MOV DX,PORT8253
MOV AL,0
OUT DX,AL;6s时间到,将0通道的计数值所存在锁存器中
MOV DX,PORT0
IN AL,DX
MOV BL,AL
IN AL,DX
MOV AH,AL
MOV AL,BL;将锁存器中的值读入AX中,先低后高
MOVB_H,AX;保护AX,存入存储器中
CMPAX,6
RET
XSENDP
RQPROC;日期显示子程序
MOV AH,2AH
INT 21H;取日期到CX,DX
MOV B_H,DX
MOV AX,CX
CALL XS
LEA DX,S3
MOV AH,09H
INT 21H
MOV DX,B_H
MOV B_H,DX;显示年
MOV AL,DH
MOVAH,0
CALL XS
LEA DX,S3
S8DB0DH,0AH,0AH,'Please input right choice y or n !','$'
S9DB0DH,0AH,0,0,0,0,0,0,0,0,0,0,'Welcome to this system(measuring range :0-9999Hz) !',0DH,0AH,0AH,0,0,0,0,0,0,0,0,0,0,'Designer:XXX',0DH,0AH,0AH,'$'