利用BIOS中断或DOS中断实现一个电子表的程序,要求精确到秒

来源:互联网 发布:2010年科比总决赛数据 编辑:程序博客网 时间:2024/05/01 05:07

;***************************************************************
;利用BIOS中断或DOS中断实现一个电子表的程序,要求精确到秒
;author:野渡无人
;create date:2007-12-31
;***************************************************************
save_reg macro
      push  ax
      push  bx
      push  cx
      push  dx
      push  si
      push  di
endm     
;***************************************************************
ret_reg macro
      pop   di
      pop   si
      pop   dx
      pop   cx
      pop   bx
      pop   ax
      ret
endm
;***************************************************************
print macro x
      mov  ah,02
      mov  dl,x
      int  21h
endm
;***************************************************************
;***************************************************************
data segment
     colon db ':'
     crlf  db 13,10,'$'
data ends
;***************************************************************
prog segment
      assume cs:prog,ds:data
;---------------------------------------------------------------
main proc far
start:
     push ds
     sub  ax,ax
     push ax
     mov  ax,data
     mov  ds,ax
rotate:
     mov  ah,2ch
     int  21h
     push dx
     mov  bl,ch
     call print_time
     print colon
     mov  bl,cl
     call print_time
     print colon
     pop  dx
     mov  bl,dh
     call print_time
     mov  ah,09
     lea  dx,crlf
     int  21h
     mov  bx,20
wait1:
      mov  cx,33144
      call waitf
      dec  bx
      jnz  wait1
      call clear_screen
      jmp  rotate
   
     ret

main endp
;---------------------------------------------------------------
print_time proc near
      save_reg
      mov  al,bl
      mov  ah,0
      mov  cx,10
      div  cl
      mov  bx,ax
      add  bl,30h
      add  bh,30h
      print bl
      print bh
      ret_reg
print_time endp
;---------------------------------------------------------------
clear_screen proc near
      save_reg
      mov  ah,6
      mov  al,0
      mov  bh,7
      mov  ch,0
      mov  cl,0
      mov  dh,24
      mov  dl,79
      int  10h
      mov  dx,0
      mov  ah,2
      int  10h
      ret_reg
clear_screen endp
;--------------------------------------------------------------------------
waitf proc near
      push ax
waitf1:
      in   al,61h
      and  al,10h
      cmp  al,ah
      je   waitf1
      mov  ah,al
      loop waitf1
      pop  ax
      ret
waitf endp
;---------------------------------------------------------------
prog ends
;***************************************************************
    end start 

原创粉丝点击