www.pudn.com > clockOfHuiBian.rar > clk.asm


data       segment para public 'data' 
count100   db 100 
tenhour    db 0 
hour       db 0,':' 
tenmin     db 0 
minute     db 0,':' 
tensec     db 0 
second     db 0 
msg        db 'Current time is(quit:ctrl+c):  ','$' 
data       ends 
 
stack      segment para stack 'stack' 
           db 256 dup(0) 
stack      ends 
 
code       segment para public 'code' 
start: 
           assume cs:code 
           mov ax,data 
           mov es,ax 
           assume es:data 
           mov si,82h 
           mov di,offset tenhour 
           mov cx,8 
           cld 
           rep movsb 
           mov ds,ax  
           assume ds:data    
           mov ah,0 
           int 16h 
           cli 
           mov ax,0                        
           mov es,ax 
           mov di,20h 
           mov ax,offset timer 
           stosw 
           mov ax,cs                                      
           stosw 
           mov al,36h 
           out 43h,al 
           mov bx,11932 
           mov al,bl 
           out 40h,al 
           mov al,bh 
           out 40h,al 
           mov al,0fch 
           out 21h,al 
           sti 
forever:   mov dx,offset msg 
           mov ah,9 
           int 21h 
           mov bx,offset tenhour 
           mov cx,8 
dispclk:   mov al,[bx]                             
           call dispchar 
           inc bx 
           loop dispclk 
           mov al,0dh 
           call dispchar 
           mov al,second 
next:      cmp al,second 
           je next 
           jmp forever 
timer proc far 
           push ax 
           dec count100 
           jnz timerx 
           mov count100,100 
           inc second 
           cmp second,'9' 
           jle timerx 
           mov second,'0' 
           inc tensec 
           cmp tensec,'6' 
           jl timerx 
           mov tensec,'0' 
           inc minute 
           cmp minute,'9' 
           jle timerx 
           mov minute,'0' 
           inc tenmin 
           cmp tenmin,'6' 
           jl timerx 
           mov tenmin,'0' 
           inc hour 
           cmp hour,'9' 
           ja adjhour 
           cmp hour,'4' 
           jnz timerx 
           cmp tenhour,'2' 
           jnz timerx 
           mov hour,'0' 
           mov tenhour,'0' 
           jmp short timerx 
adjhour:   inc tenhour 
           mov hour,'0' 
timerx:    mov al,20h 
           out 20h,al 
           pop ax 
           iret 
timer      endp 
dispchar   proc near 
           push bx 
           mov bx,0 
           mov ah,14 
           int 10h 
           pop bx 
           ret 
dispchar   endp 
code       ends 
           end start