[汇编] 屏幕中间显示数字时钟

 

 

 

  1 ;显示系统时间程序
  2 
  3 data segment
  4     ; add your data here! 
  5     hour db '?'
  6     minute db '?'
  7     second db '?'
  8     time db   "00:00:00$"  
  9     temp db '?'  
 10     now  db '?'
 11     want db '?'
 12     pkey db "press any key...$"
 13 ends
 14 
 15 stack segment
 16     dw   128  dup(0)
 17 ends
 18 
 19 code segment
 20 ;---------------------------------------------
 21 main proc far
 22     call init_register  ;初始化 
 23 SiXunHuan:
 24     mov want,1D         ;延时3S
 25     call delay                  
 26     call setshow
 27     call show_time      ;显示  
 28     loop SiXunHuan
 29     
 30     call last_show      ;结果
 31     ret
 32 main endp;    
 33 ;---------------------------------------------
 34 init_register proc near;set segment registers:
 35     mov ax, data
 36     mov ds, ax
 37     mov es, ax 
 38     ret   
 39 init_register endp
 40 ;---------------------------------------------
 41 show_time proc near ;时间子程序   
 42     mov ah,2Ch
 43     int 21h         ;获取时间
 44     mov hour,ch
 45     mov minute,cl
 46     mov second,dh
 47 
 48     mov ax,0        ;计算到字符串时间
 49     mov al,hour 
 50     mov temp,10D
 51     div temp
 52     add al,30H
 53     mov time[0],al
 54     add ah,30H
 55     mov time[1],ah
 56       
 57     mov ax,0
 58     mov al,minute 
 59     mov temp,10D
 60     div temp
 61     add al,30H
 62     mov time[3],al
 63     add ah,30H
 64     mov time[4],ah   
 65     
 66     mov ax,0
 67     mov al,second 
 68     mov temp,10D
 69     div temp
 70     add al,30H
 71     mov time[6],al
 72     add ah,30H
 73     mov time[7],ah   
 74         
 75     lea dx,time     ;10中断显示时间
 76     mov ah,09H
 77     int 21H 
 78     
 79     ret
 80 show_time endp   
 81 ;---------------------------------------------
 82 last_show proc near ;最后显示东西  
 83     lea dx, pkey   ; output string at ds:dx
 84     mov ah, 9
 85     int 21h        
 86     
 87     ; wait for any key....and end    
 88     mov ah, 1
 89     int 21h
 90     
 91     mov ax, 4c00h ; exit to operating system.
 92     int 21h  
 93     ret
 94 last_show endp  
 95 ;---------------------------------------------  
 96 delay proc near     ;延时函数,放在want为想要延时的秒数
 97     mov ah,2Ch
 98     int 21h         ;获取时间 
 99     mov now,dh
100     
101     mov ax,0
102     mov al,now 
103     add al,want
104     mov temp,60D
105     div temp
106     mov want,ah  
107 del:
108     mov ah,2Ch
109     int 21h
110     cmp dh,want
111     jz  next
112     loop del
113 next:
114     ret
115 delay endp      
116 ;--------------------------------------------- 
117 setshow proc near   ;设置光标位置位置  
118     mov dh,12      ;row-1
119     mov dl,34      ;columun-1
120     mov bh,0
121     mov ah,2
122     int 10h
123 setshow endp  
124 ;--------------------------------------------- 
125 clear proc near
126     ret
127 clear endp
128 ;--------------------------------------------- 
129 end code
130 end

 

posted @ 2014-06-05 17:43  beautifulzzzz  阅读(1422)  评论(0编辑  收藏  举报