首页 > 编程 > ASM > 正文

汇编语言简易时钟

2019-11-10 18:51:14
字体:
来源:转载
供稿:网友

代码解释如下:

;从CMOS RAM中读取存储的时间信息,显示当前的系统时间在屏幕上assume cs:codedata segment	db 'YY MM DD HH MM SS',0     	  ;时间以这个形式显示data endscode segmentinfo: 			db 9,8,7,4,2,0			;标志年 月 日 时 分 秒不同时间的位置start:			call init_regtimeChange:		call show_clock			;一直在这里循环不断更新时间				jmp timeChange				mov ax,4c00h				int 21h;========================================================init_reg:		mov ax,0B800h				mov es,ax				mov ax,cs				mov ds,ax				mov di,160*12 + 40*2				mov si,offset info				mov cx,6				ret;========================================================show_clock:		push dx				push es				push di				push si				push ds				push cx				showTime:		mov al,ds:[si]								out 70h,al					;向70h号端口输出al				in al,71h					;在71h号端口读取数据放入al				mov ah,al				shr ah,1					;这个了用4个shr,主要是为了不破坏cx的值				shr ah,1				shr ah,1				shr ah,1				and al,00001111B				add ah,30h					;add 30h 就转为能看懂的ASCII码				add al,30h				mov es:[di],ah				mov es:[di+2],al				inc si						;标志不同时间(月年日时分秒)的位置更新				add di,6								loop showTimeshowClockRet:	pop cx				pop ds				pop si				pop di				pop es				pop dx				ret;========================================================			code endsend start


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选