文件名称:用汇编做的钟(时间与系统的同步)
文件大小:822B
文件格式:EXE
更新时间:2012-07-04 08:12:01
用汇编做的钟
时间与系统的同步 代码如下: assume cs:code data segment db 20 dup(0) data ends qw segment db'Press "Q" to quit',0 qw ends code segment start:mov bx,0b800h mov es,bx mov ax,qw mov ds,ax mov ch,0 mov di,0 mov si,0 sh:mov cl,ds:[si] jcxz redo mov es:[160*10+30*2+di],cl inc si inc di inc di jmp sh redo: mov bx,data mov ds,bx mov si,0 mov di,0 mov cx,10 mov bl,0 s:mov al,bl out 70h,al in al,71h mov ah,al shr ah,1 shr ah,1 shr ah,1 shr ah,1 and al,00001111b add al,30h add ah,30h mov ds:[si],al mov ds:[1+si],ah add si,2 inc bl loop s mov si,0 mov di,22 mov al,ds:[si] ;显示秒 mov ah,ds:[si+1] mov byte ptr es:[160*12+34*2-di],':' mov es:[160*12+35*2-di],ah mov es:[160*12+36*2-di],al sub di,6 ;显示分 add si,4 mov al,ds:[si] mov ah,ds:[si+1] mov byte ptr es:[160*12+34*2+di],':' mov es:[160*12+35*2+di],ah mov es:[160*12+36*2+di],al sub di,6 ;显示时 add si,4 mov al,ds:[si] mov ah,ds:[si+1] mov es:[160*12+35*2+di],ah mov es:[160*12+36*2+di],al sub di,8 add si,6 mov al,ds:[si] mov ah,ds:[si+1] mov byte ptr es:[160*12+34*2+di],'/' mov es:[160*12+35*2+di],ah mov es:[160*12+36*2+di],al sub di,6 add si,2 mov al,ds:[si] mov ah,ds:[si+1] mov byte ptr es:[160*12+34*2+di],'/' mov es:[160*12+35*2+di],ah mov es:[160*12+36*2+di],al sub di,6 add si,2 mov al,ds:[si] mov ah,ds:[si+1] mov es:[160*12+35*2+di],ah mov es:[160*12+36*2+di],al in al,60h cmp al,10h je ok jmp redo ok:mov ax,4c00h int 21h code ends end start