Изучение принципов обработки аппаратных прерываний, страница 8

      cssave_8 dw 0h

adr_int60: 

      ipsave_60 dw 0h  

      cssave_60 dw 0h  

      msg db '   :  :  $'

dseg ENDS

cseg SEGMENT

main proc FAR

      ASSUME      cs:cseg, ds:dseg, ss:sseg

start:

      mov ax, dseg     

      mov ds, ax

      mov ax,3508h     

      int 21h

      mov ipsave_8, bx 

      mov ax, es

      mov cssave_8, ax

      mov ax,3560h     

      int 21h

      mov ax, es

      mov cssave_60, ax

      push ds

      mov dx, offset int_8   

      mov ax, seg int_8

      mov ds, ax       

      mov ax,0

      mov di,8h

      mov es,ax

      shl di,2h

      cli              

      mov es:[di],dx

      mov ax,ds

      mov es:[di]+2,ax

      sti              

      pop ds

      push ds

      mov dx, offset int_60  

      mov ax, seg int_60     

      mov ds, ax       

      mov ax,0

      mov di,60h

      mov es,ax

      shl di,2h

      cli                    

      mov es:[di],dx

      mov ax,ds

      mov es:[di]+2,ax

      sti              

      pop ds

      mov al,2

      out 21h,al       

time:                  

      cmp flag,0       

      je exit    

      mov flag,0             

      mov ax,sec       

      mov bl,10              

      div bl

      add ax,3030h           

      mov word ptr es:msg+7,ax

      mov ax,min       

      div bl                      

      add ax,3030h           

      mov word ptr es:msg+4,ax

      mov ax,hour      

      div bl                      

      add ax,3030h           

      mov word ptr es:msg+1,ax

      mov ax,0B800h          

      mov es,ax

      lea bx,msg             

      mov di,0         

mn1:

      mov al,[bx]

      cmp al,'$'

      je exit

      mov es:[di],al

      inc di

      inc bx

      mov es:[di],word ptr 0F0h

      inc di

      jmp mn1

exit:

      cmp sec,20

      jne time

      mov al,0               

      out 21h,al

      mov ax,0h                   

      int 16h

      push ds

      mov dx, ipsave_8

      mov ax, cssave_8

      mov ds, ax

      mov ax,0

      mov di,8h

      mov es,ax

      shl di,2h

      cli              

      mov es:[di],dx

      mov ax,ds

      mov es:[di]+2,ax

      sti              

      pop ds

      push ds

      mov dx, ipsave_60

      mov ax, cssave_60

      mov ds, ax

      mov ax,0

      mov di,60h

      mov es,ax

      shl di,2h

      cli              

      mov es:[di],dx

      mov ax,ds

      mov es:[di]+2,ax

      sti              

      pop ds

      mov ah,4ch       

      int 21h

main  ENDP

int_8 proc FAR              

      push ax                

      push es                     

      mov ax, dseg

      mov es,ax

      mov ax,word ptr es:cnt 

      inc ax

      cmp ax,18        

      jne m0                 

      int 60h

      mov ax,0

m0:

      mov word ptr es:cnt,ax

      pop es

      pop ax

      mov ax,dseg

      mov es,ax

      jmp dword ptr es:adr_int8