www.pudn.com > cesu.rar > speed.asm, change:2009-05-16,size:12603b


 
	 
;	$INCLUDE (REG52.INC) 
	DISPBUF	EQU	59H 	;显示缓冲区从5AH开始 
	SecCoun	EQU	58H 
	SpCoun	EQU	56H	;速度计时器单元57H和58H,高位在前(57H单元中) 
	Count	EQU	55H;	显示时的计数器 
	SpCalc	bit	00h	;要求计算速度的标志,该位为1则主程序进行速度计算,然后清该位 
	Hidden	EQU	16	;消隐码 
	 
	ORG	0000H 
	AJMP	START 
	ORG	1BH 
	JMP	TIMER1		;定时中断1入口 
 
	ORG	30H 
START:	MOV	SP,#5FH		;设置堆栈 
	MOV	P1,#0FFH 
	MOV	P0,#0FFH 
	MOV	P2,#0FFH	;初始化,所有显示器、LED灭 
	MOV	TMOD,#00010101B	;定时器T1工作于方式1,定时器0工作方式1,计数器 
	MOV	TH1,#HIGH(65536-3686) 
	MOV	TL1,#LOW(65536-3686) 
	SETB	TR1 
	SETB	ET1		;开定时器1中断 
	SETB	EA 
 
LOOP:	JNB	SpCalc,LOOP	;如果未要求计算,转本身循环 
 
;标号: MULD    功能:双字节二进制无符号数乘法 
;入口条件:被乘数在R2、R3中,乘数在R6、R7中。 
;出口信息:乘积在R2、R3、R4、R5中。 
;影响资源:PSW、A、B、R2~R7    堆栈需求:  2字节 
	MOV	R2,SpCoun 
	MOV	R3,SpCoun+1 
	MOV	R6,#0 
	MOV	R7,#5		;测得的数值是每秒计数值,转为分(每一转测12次,故乘5而非60) 
	CALL	MULD 
 
SEND:	MOV	SBUF,R2 
SLP1:	JBC	TI,SN1		;是否送完? 
	AJMP	SLP1 
SN1:	MOV	SBUF,R3 
SLP2:	JBC	TI,SN2 
	AJMP	SLP2 
SN2:	MOV	SBUF,R4 
SLP3:	JBC	TI,SN3 
	AJMP	SLP3 
SN3:	MOV	SBUF,R5 
SLP4:	JBC	TI,SN4 
	AJMP	SLP4 
SN4: 
;标号: HB2   功能:双字节十六进制整数转换成双字节BCD码整数 
;入口条件:待转换的双字节十六进制整数在R6、R7中。 
;出口信息:转换后的三字节BCD码整数在R3、R4、R5中。 
;影响资源:PSW、A、R2~R7    堆栈需求:  2字节 
	MOV	A,R4 
	MOV	R6,A 
	MOV	A,R5 
	MOV	R7,A	;将乘得的结果送R6R7准备转换,这里结果不可能超过2字节 
	CALL	HB2 
 
	MOV	DISPBUF,R3	;最高位 
	 
	MOV	A,R4		; 
	ANL	A,#0F0H		;去掉低4位 
	SWAP	A		;将高4位切换到低4位 
	MOV	DISPBUF+1,A 
 
	MOV	A,R4 
	ANL	A,#0FH 
	MOV	DISPBUF+2,A 
	 
	MOV	A,R5 
	ANL	A,#0F0H 
	SWAP	A 
	MOV	DISPBUF+3,A 
	 
	MOV	A,R5 
	ANL	A,#0FH 
	MOV	DISPBUF+4,A 
	 
	CLR	SpCalc		;清计算标志 
	JMP	LOOP 
	 
;主程序到此结束 
TIMER1:	PUSH	ACC		;ACC入栈 
	PUSH	PSW		;PSW入栈 
	SETB	RS0		;工作区1 
	JNB	TR0,SETTR0	;如果T0未运行,则开启T0 
	JMP	GO1 
SETTR0: 
	SETB	TR0 
GO1:	 
	INC	SecCoun		;秒计数器加1 
	MOV	A,SecCoun 
	CJNE	A,#251,Go2	;如果未到1s则转(每到1S停1次,故数值为251) 
	CLR	TR0		;1s到了,则停止T0的运行 
	MOV	SpCoun,TH0 
	MOV	SpCoun+1,TL0	;读取计数值 
	CLR	A 
	MOV	TH0,A 
	MOV	TL0,A		;清计数器 
	SETB	SpCalc		;要求主程序计算速度 
	MOV	SecCoun,#0	;清秒计数器 
Go2:	 
	INC	COUNT       ;用于显示的计数器 
	MOV	A,COUNT 
	CLR	C 
	SUBB	A,#6 
	JZ	N1 
	JMP	N2 
N1:	MOV	COUNT,#0 
N2:	MOV	A,#DISPBUF 
	ADD	A,COUNT	 
	MOV	R0,A		;指向当前要显示的显示缓冲区 
	MOV	A,@R0		;取第一个待显示数 
	MOV	DPTR,#DISPTAB	;字形表首地址 
	MOVC	A,@A+DPTR 	;取字形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