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

📄 sy.asm

📁 这段小程序是在dos操作系统下运行的汇编语言程序
💻 ASM
字号:
data segment
	space	db 1000 dup(' ')
		inf	db		0dh,0ah,'the time is:','$'
	   str1	db		8	dup(':')   
	sec	dw	0
	 min	dw	0
	hour	dw	0
data ends
stack1 segment	stack
	dw	200	dup(0)
stack1	ends
code segment
	assume cs:code,ds:data,es:data,ss:stack1
start:	mov	ax,0001h
		int		10h
		mov	ax,data
		mov	ds,ax
		mov	es,ax
		;lea	bp,space
		;mov	dx,0b00h
		;mov	cx,1000
		;mov	bx,000fh
		;mov	ax,1300h
		;int		10h
		mov	dx,offset	inf
		mov	ah,9
		int		21h
		mov 	ah,8
		int		21h
		;cmp	al,'D'				;'D'或'd':显示日期,'T'或't':显示时间,'Q'或'q':返回dos状态
		;jne		A
		;call	date
;A:		cmp	al,'d'
;		jne		B
		;call	date					;'D'或'd'时调用日期显示函数
B:		cmp	al,'T'
		jne		C
		call	time					;'t'或'T'显示时间
C:		cmp	al,'t'
		jne		D
		call 	time
D:		cmp	al,'Q'
		jne		E
		call	exit
E:		cmp	al,'q'				;'q'或'Q'返回dos状态
		jne		start
exit:	mov	ah,4ch
		int		21h

time	proc near
disp:	mov	si,0
		mov	bx,100
		;div		bl
		;mov	bl,0
		;mov 	bh,0
		mov	ah,2ch
		int		21h					;取系统时间
		mov	al,ch					;取小时
		call	bcdasc				;将十进制化为ASCII码字符
		inc 	si						;小时与分钟之间插入一个冒号
		mov	al,cl					;取分钟		
		call	bcdasc
		inc		si						;分钟与秒之间插入一个冒号
		mov	al,dh					;取秒
		call	bcdasc
		lea		bp,str1				;显示时间
		mov	dx,180dh				;起始显示坐标
		mov	cx,20					;要显示的字符串的长度
		mov	bx,000fh
		mov	ax,1301h
		int		10h
		mov	ah,01h				;调用16号中断——键盘服务
		int		16h					;出口参数为ZF,ZF=1表示普通键盘没有键被按下
		jz		disp					;当普通键盘没有键按下时就重复执行显示时间的函数
		jmp	start
time	endp
bcdasc	proc	near
		push	bx
		cbw							;字节转换成字
		mov	bl,10
		div		bl						;al除以10得到的商放在al中,余数放在ah中,也就是时/分/秒的十位和个位
		add	al,'0'
		mov	str1[si],al			;将时/分/秒的十位放入数组str中,便于显示
		inc		si						;地址指针指向个位要存储的空间
		add	ah,'0'
		mov	str1[si],ah
		inc		si
		pop	bx
		ret
bcdasc	endp
code ends
end	start

⌨️ 快捷键说明

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