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

📄 shuzishizhong.asm.txt

📁 1. 能显示系统当前时间
💻 TXT
📖 第 1 页 / 共 3 页
字号:

name 		Clock.asm
include 		Clock.lib
DATA 		SEGMENT
icon			db	1h
ptitle		db	'Clock'
read_me		db	'********************************'
			db	'           Read Me...           '
			db	'  The application is the clock  '
			db	'  running under the enviroment  '
			db	'  of the DOS. Using the Color  '
			db	'   Text Mode to display the sy-  '
			db	'  stem time. And when it comes '
			db	'   to integral point, the appl- '
			db	'   ication will drive the beep  '
			db	'   to play sounds. The status b '
			db	'   ar will show status of the c '
			db	'   lock.If you want to quit,En- '
			db	'   ter the key "Q" to get to q- ' 
			db	'   uit interface, then enter "R"' 
			db	'   will get back to the applica '
			db	'   tion interface.               '
			db	'--------------------------------' 
			db	'      Author:zhouyonghao        '
			db	'   Scholar number:012002013526  '
			db	'   Computer science 0203,HUST   '
			db	'********************************' 
tip1			db	'The digital clock has been started!'
tip3			db	'Thank for using,BYE!'
tip4			db	"Press the key 'R' to get back "
tip5			db	'Current time is:'
tip6			db	'press the key "Q" to EXIT...',0
filler		db	'                                        '
curr_h1		db 				?
curr_h2		db 				?
curr_m1		db		 		?
curr_m2		db 				?
curr_s1		db 				?
curr_s2		db 				?
time_buff	db				6	dup(0)
isring		db				0	;如果是整点isring=1并报时
iskey		db				0	
FreqData	DW 			330,294,262,294,3 dup(330)
			DW 			3 dup(294),330,392,392
			DW 			330,294,262,294,4 dup(330)
			DW 			294,294,330,294,262,-1
LongingTime DW 			6 dup(1000),2000
			DW 			2 dup(1000,1000,2000)
			DW 			12 dup(1000),4000
DATA 		ENDS
STACK 		SEGMENT 	STACK
      		DB 			200 	DUP(0)
STACK 		ENDS
CODE 		SEGMENT 	'CODE'
     		ASSUME 	CS:CODE,DS:DATA,SS:STACK,es:data
start:					mov 			ax,data
    mov 				ds,ax
	mov 				es,ax
Display:
	mov 				ah,0									;初始化屏幕开始
	mov 				al,03h								;初始化屏幕结束
	int 					10h	
	SetCursor 			1 									;隐藏光标		
	DrawWindow 		70h,0,0,0,79;
	DrawWindow 		70h,24,0,24,79
	DrawWindow 		1eh,1,0,23,79
	DrawWindow 		0ceh,1,0,23,32
	SetPos 				1,0
	WindowUBBand 		0d5h,0cdh,0b8h,1,0,80,1eh
	mov 				al,2
draw1:					WindowLRBand 	0b3h,al,0,80,1eh
	inc 					al
	cmp 				al,17h
	jne 					draw1
	WindowUBBand 		0c0h,0c4h,0d9h,23,0,80,1eh
	OutPutStr 			icon,1,0,1,74h
	OutPutStr 			ptitle,5,0,35,70h
	OutPutStr 			tip1,35,24,0,70h
	OutMultilineStrs		read_me,32,21,2,1,4Bh
	mov 				al,2
draw2:					WindowLRBand 	0b3h,al,33,1,1eh
	inc 					al
	cmp 				al,17h
	jne 					draw2
	OutPutStr 			tip5,16,3,34,13h
	DrawWindow 		2eh,6,39,14,74						;绘出数字钟的表盘
	SetPos				8,50
	OutPutChar 			3h,1eh,1
	SetPos 				12,50
	OutPutChar 			3h,1eh,1
	SetPos				8,62
	OutPutChar 			3h,1eh,1
	SetPos 				12,62
	OutPutChar 			3h,1eh,1
	GetSysTime 			curr_h1,curr_h2,curr_m1,curr_m2,curr_s1,curr_s2
	EVAFigure			curr_h1,40,1eh
	EVAFigure			curr_h2,45,1eh
	EVAFigure			curr_m1,52,1eh
	EVAFigure			curr_m2,57,1eh
	EVAFigure			curr_s1,64,1eh
	EVAFigure			curr_s2,69,1eh
	mov 				cx,0
l_in:
	IsKeyDown			exit,isIntergeTime
isIntergeTime:
	IsTimeAlert
	cmp 				isring,0
	je					DisplayTime
	call 				SoundMusic
DisplayTime:
	ShowTime			1eh
	jmp 				l_in
exit:	DrawWindow 		1eh,0,0,24,79
	OutPutStr 			tip3,20,8,30,01bh
	OutPutStr 			tip4,30,12,25,09fh
	OutPutStr 			tip6,28,13,25,09fh
l_quit:
	mov 				ah,6
	mov					dl,0ffh
	int					21h
	cmp  				al,'R'
qq	je					Display
	cmp					al,'r'
	je					Display
	cmp 				al,'q'
	je					Exit_App
	cmp 				al,'Q'
	je					Exit_App
	jmp					l_quit		
Exit_App:
	mov					ah,4ch
    int					21h
SoundMusic		proc	
	push  				ax
	push  				bx
    push  				cx
    push  				dx
    push  				si
    push  				di
	push   				bp 
    lea    				si,FreqData
    lea    				bp,ds:LongingTime
L_Freqence:   			mov  di,[si]
	cmp  				di,-1
	je					EndPlay
	mov  				bx,ds:[bp]
	call					Play
	add  				si,2
	add  				bp,2
    jmp  				DisplayTime;L_Freqence
EndPlay:       
	pop 				bp
	pop 				di 
	pop 				si
	pop 				dx
	pop 				cx
	pop 				bx
	pop 				ax    
SoundMusic				endp  
Play 		proc  		far
	push  				ax
	push  				bx
    push  				cx
    push  				dx
    push  				di
    mov   				al,0b6h
    out   				43h,al
    mov   				dx,12h
    mov   				ax,3280h
    div   				di
    out   				42h,al
    mov   				al,ah
    out   				42h,al
    in    				al,61h
    mov   				ah,al
    or    				al,3
    out   				61h,al
Stop:   					mov     	cx,55afh
Pause:  					loop   		Pause
    dec    				bx
    jne     				Stop
    mov     			al,ah
    out     				61h,al
    pop 				di 
	pop 				dx
	pop 				cx
	pop 				bx
	pop 				ax     
    ret
Play   					endp
CODE 		ENDS
     		END 		start
;//宏库clock.lib文件
STACK0 MACRO		A
	STACK SEGMENT PARA STACK 'STACK'
						DB A DUP(0)
						STACK ENDS
	ENDM
SetPos 					macro top,left				;设置光标位置
	mov ah,02h
	mov bx,0
	mov dh,top
	mov dl,left
	int 10h
	endm
DrawWindow 			macro attr,top,left,bottom,right	;绘制窗口
	push ax
	push bx
	push cx
	push 				dx
	mov				 	ah,06h
	mov 				al,0
	mov 				bh,attr 
	mov 				ch,top
	mov 				cl,left
	mov 				dh,bottom
	mov 				dl,right
	int 					10h
	pop 				dx
	pop 				cx
	pop 				bx
	pop 				ax
	endm
WindowUBBand 			macro l,m,r,top,left,width,attr	;绘制窗口上下边框
	SetPos 				top,left
	outputchar 			l,attr,1
	SetPos 				top,left+1
	outputchar 			m,attr,width-2
	SetPos 				top,left+width-1
	outputchar 			r,attr,1
	endm
WindowLRBand 			macro char,top,left,width,attr	;绘制窗口左右边框
	SetPos 				top,left
	outputchar 			char,attr,1
	SetPos 				top,left+width-1
	outputchar 			char,attr,1
	endm
OutPutChar 				macro char,attr,num			;输出字符
	push 				ax
	mov 				bh,0
	mov 				ah,09h
	mov 				al,char
	mov 				bl,attr
	mov 				cx,num
	int 					10h
	pop 				ax
	endm
OutPutStr 				macro str,num,top,left,attr		;输出字符串
	push 				ax
	push 				bx
	push 				bp
	push 				cx
	push 				dx
	mov 				ah,13h
	lea 					bp,str
	mov 				cx,num
	mov 				dh,top
	mov 				dl,left
	mov 				bh,0
	mov 				al,1
	mov 				bl,attr
	int 					10h
	pop 				dx
	pop 				cx
	pop 				bp
	pop 				bx
	pop 				ax
	endm
SetCursor 				macro show				;设置光标属性
	push 				ax
	push 				cx
	mov 				ah,1
	mov 				cl,0
	mov 				ch,show
	int 					10h
	pop	 				cx
	pop 				ax
	endm
GetSysTime				macro	a,b,c,d,e,f;或取当前的系统时间,并保存至data段中
	local 				c1,c2,c3,c4,c5,c6
	mov 				ah,2ch
	int 					21h
	push 				cx
	push 				cx
	push 				cx;计算小时并保存
	mov 				cl,4
	shr 					ch,cl
	mov 				al,ch
	mov 				ah,16
	mul 				ah
	pop 				cx
	and	 				ch,0fh
	add 				al,ch
	mov 				ah,0
	mov 				bl,10
	div 					bl
	mov 				a,al
	mov 				b,ah
	pop 				cx	;计算分钟并保存
	mov 				al,cl
	mov 				cl,4
	shr 					al,cl
	mov 				ah,16
	mul 				ah
	pop 				cx
	and 				cl,0fh
	add 				al,cl
	mov 				ah,0
	mov 				bl,10
	div 					bl
	mov 				c,al
	mov 				d,ah
	push 				dx		;计算秒并保存
	mov 				al,dh
	mov 				cl,4
	shr 					al,cl
	mov 				ah,16
	mul 				ah
	pop 				dx
	and 				dh,0fh
	add 				al,dh
	mov 				ah,0
	mov 				bl,10
	div 					bl
	mov 				e,al
	mov 				f,ah
	endm	 
IsTimeChanged			macro	;判断当前取得的时间与时间缓冲区中的值是否相同
	local 				l_judge,changed,quit,l_send
	push 				cx
	lea 					si,curr_h1
	lea	 				di,time_buff
	mov 				cx,6
l_send:					mov al,[si]
	mov 				[di],al
	inc 					si
	inc 					di
	dec 					cx
	jnz					l_send
	GetSysTime 			curr_h1,curr_h2,curr_m1,curr_m2,curr_s1,curr_s2
	lea 					si,curr_h1+5
	lea 					di,time_buff+5
	mov 				cx,6
l_judge:					mov ah,[si]
	cmp 				ah,[di]
	jne 					changed
	dec 					si
	dec 					di
	dec 					cx
	jnz 					l_judge
	mov 				istchanged,byte ptr 0
	jmp 				quit
changed:					mov istchanged,byte ptr 1
quit:					pop cx
	endm
OutMultilineStrs 			macro str,num,linenum,beginln,begincol,attr
	local 				l_multiln
	push 				ax
	push 				bx
	push 				bp
	push 				cx
	push 				dx
	mov 				ch,linenum
	lea 					bp,str
	mov 				cl,beginln
l_multiln:				mov ah,13h
	mov 				dh,cl
	mov 				dl,begincol
	push 				cx
	mov 				cx,num
	mov 				bh,0
	mov 				al,1
	mov 				bl,attr
	int 					10h
	pop 				cx
	add 				bp,num
	inc 					cl
	dec 					ch
	jnz	 				l_multiln
	pop 				dx
	pop 				cx
	pop 				bp
	pop 				bx
	pop				 	ax
	endm
Num0					macro left,attr				;显示数字0
	local 				draw
	push 				ax
	mov 				ax,0
	mov 				al,7
draw:					WindowLRBand 0b3h,al,left,4,attr
	inc 					al
	cmp 				al,14
	jne 					draw
	SetPos 				7,left
	OutPutChar 			0c4h,attr,4
	SetPos 				13,left
	OutPutChar			0c4h,attr,4
	pop 				ax
	endm
Num1					macro left,attr
	local 				draw
	push 				ax
	mov 				al,7
draw:					WindowLRBand 0b3h,al,left+3,1,attr
	inc 					al
	cmp 				al,14
	jne 					draw
	SetPos 				7,left
	OutPutChar		 	0c4h,attr,0
	SetPos 				13,left
	OutPutChar 			0c4h,attr,0
	pop 				ax
	endm
Num2					macro left,attr
	local 				draw1,draw2
	push 				ax
	mov 				al,7
draw1:					WindowLRBand 0b3h,al,left+3,1,attr
	inc 					al
	cmp 				al,10
	jne 					draw1
draw2:					WindowLRBand 0b3h,al,left,1,attr
	inc 					al
	cmp 				al,14
	jne 					draw2
	SetPos 				7,left
	OutPutChar 			0c4h,attr,4
	SetPos 				13,left
	OutPutChar			0c4h,attr,4
	SetPos 				10,left
	OutPutChar 			0c4h,attr,4
	pop 				ax
	endm
Num3					macro left,attr
	local 				draw
	push 				ax
	mov 				al,7
draw: 					WindowLRBand 0b3h,al,left+3,1,attr
	inc 					al
	cmp 				al,14
	jne 					draw
	SetPos 				7,left
	OutPutChar 			0c4h,attr,4
	SetPos 				13,left
	OutPutChar 			0c4h,attr,4
	SetPos 				10,left
	OutPutChar 			0c4h,attr,4
	pop 				ax
	endm
Num4					macro left,attr
	local 				draw1,draw2
	push 				ax
	mov 				al,7
draw1: 					WindowLRBand 0b3h,al,left,4,attr
	inc 					al
	cmp 				al,10
	jne 					draw1
draw2: 					WindowLRBand 0b3h,al,left+3,1,attr
	inc 					al
	cmp 				al,14
	jne 					draw2
	SetPos 				10,left
	OutPutChar 			0c4h,attr,4
	pop 				ax
	endm
Num5					macro left,attr
	local 				draw1,draw2
	push 				ax
	mov 				al,7
draw1: 					WindowLRBand 0b3h,al,left,1,attr
	inc 					al
	cmp 				al,10
	jne 					draw1
draw2: 					WindowLRBand 0b3h,al,left+3,1,attr
	inc 					al
	cmp 				al,14
	jne 					draw2
	SetPos 				7,left
	OutPut				Char 0c4h,attr,4
	SetPos 				13,left
	OutPutChar 			0c4h,attr,4
	SetPos 				10,left
	OutPutChar 			0c4h,attr,4
	pop 				ax
	endm
Num6					macro left,attr
	local 				draw1,draw2
	push 				ax
	mov 				al,7
draw1: 					WindowLRBand 0b3h,al,left,1,attr
	inc 					al
	cmp 				al,10
	jne 					draw1
draw2: 					WindowLRBand 0b3h,al,left,4,attr
	inc 					al
	cmp 				al,14
	jne 					draw2
	SetPos 				7,left
	OutPutChar 			0c4h,attr,4
	SetPos 				13,left
	OutPutChar 			0c4h,attr,4
qq	SetPos 				10,left
	OutPutChar 			0c4h,attr,4
	pop 				ax
	endm
Num7					macro left,attr
	local 				draw
	push 				ax
	mov 				al,7
draw: 					WindowLRBand 0b3h,al,left+3,1,attr
	inc 					al
	cmp 				al,14
	jne 					draw
	SetPos 				7,left
	OutPutChar			0c4h,attr,4
	pop 				ax
	endm
Num8					macro left,attr	
	local 				draw
	push 				ax
	mov 				ax,0
	mov 				al,7
draw: 					WindowLRBand 0b3h,al,left,4,attr
	inc 					al
	cmp 				al,14
	jne 					draw
	SetPos 				7,left
	OutPutChar			0c4h,attr,4
	SetPos 				10,left
	OutPutChar 			0c4h,attr,4
	SetPos 				13,left
	OutPutChar 			0c4h,attr,4
	pop 				ax
	endm
Num9					macro left,attr
	local 				draw1,draw2
	push 				ax
	mov 				al,7
draw1: 					WindowLRBand 0b3h,al,left,4,attr
	inc 					al
	cmp 				al,10
	jne 					draw1
draw2: 					WindowLRBand 0b3h,al,left+3,1,attr
	inc 					al
	cmp 				al,14
	jne 					draw2
	SetPos 				7,left
	OutPutChar 			0c4h,attr,4
	SetPos 				10,left
	OutPutChar 			0c4h,attr,4
	SetPos 				13,left
	OutPutChar 			0c4h,attr,4
	pop 				ax
	endm

EVAFigure				macro		figure,left,attr;判断保存的时间数值
	local					t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,got
	cmp 				figure,0
	jne 					t1
	Num0				left,attr
t1:	cmp 				figure,1
	jne 					t2
	Num1				left,attr
	jmp 				got
t2:	cmp 				figure,2
	jne 					t3
	Num2				left,attr

⌨️ 快捷键说明

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