回 帖 发 新 帖 刷新版面

主题:超难啊对我来说!!来帮忙啊

问为什么这程序显示的时间与系统不能同步
错在哪里了



stack segment stack
  dw  80h dup(0)
stack  ends
data  segment
  count dw  1
  x     db  0
data  ends
code segment
  assume cs:code,ds:data,ss:stack
main proc far
start:
  mov  ax,data
  mov  ds,ax
  
  mov  al,1ch
  mov  ah,35h
  int  21h
  push  es
  push  bx
  push  ds
  
  mov   dx,offset show_systime
  mov   ax,seg show_systime
  mov   ds,ax
  mov   al,1ch
  mov   ah,25h
  int   21h
  
  pop   ds
  in    al,21h
  and   al,11111110b
  out   21h,al
  
  sti
  mov   di,2000
delay:
  mov   si,3000
delay1:
  dec   si
  jnz   delay1 
  dec   di
  jnz   delay
  mov    ah,0
  int    16h
  pop  dx
  pop  ds
  mov  al,1ch
  mov  ah,25h
  int   21h
  
  mov   ah,4ch
  int  21h
main endp

show_systime proc near
   push  ds
   push  ax
   push  cx
   push  dx
   mov   ax,data
   mov   ds,ax
   sti
   dec count
   jnz  exit
   
   call   systime1
   mov  count,10
exit:
   cli
   pop   dx
   pop   cx
   pop   ax
   pop   ds
   iret
show_systime endp
   
systime1  proc  near  ;取系统时间
   push  bx
   push  ax
   push  cx
   push  dx
   pushf
   push  ds
   mov   ah,2ch
   int   21h
   
   mov   al,ch
   mov   x,71
   call  set_curisor
   call  bin_to_dex  ;时
   mov   dl,':'
   mov   ah,02h
   int   21h
   
   mov   al,cl
   add   x,3
   call  set_curisor
   call  bin_to_dex  ;分
   mov   dl,':'
   mov   ah,02h
   int   21h
   
   mov   al,dh   ;秒
   add   x,3
   call  set_curisor
   call  bin_to_dex 
   pop   ds
   popf 
   pop   dx
   pop   cx
   pop   ax
   pop   bx
   ret
systime1 endp

bin_to_dex proc near  ;数值转为10进制输出
   push  ax
   push  dx
   push  bx
   push  cx
   pushf
   xor   dx,dx
   cbw    ;al扩展为ax
   mov   bx,10
   div   bx
   mov   bx,dx  ;保存余数
   mov   dl,al
   add   dl,30h
   mov   ah,02h
   int   21h
   
   mov   dx,bx
   add   dl,30h
   mov   ah,02h
   int   21h
   popf
   pop  cx
   pop   bx
   pop   dx
   pop   ax
   ret
bin_to_dex  endp

set_curisor  proc near  ;置光标的位置


在线等。。。。。。。。。。。
等啊等


谢谢!
   push  ax
   push  bx
   push  dx
   mov   bh,0
   mov   dh,24
   mov   dl,x
   mov   ah,2h
   int   10h
   pop   dx
   pop   bx
   pop   ax
   ret
set_curisor  endp

clear_screen  proc near
   push  ax
   push  bx
   push  cx
   push  dx
   mov   ah,6
   mov   al,0
   mov   bh,7
   mov   ch,0
   mov   ch,0
   mov   dh,24
   mov   dl,79
   int   10h
   pop   dx
   pop    cx
   pop   bx
   pop   ax
   ret
code ends
end start


   
   
   
   
   
   

回复列表 (共2个回复)

沙发

试着编译了一下, 和系统时间一样啊

板凳

stack segment stack
  dw  80h dup(0)
stack  ends
data  segment
  count dw  1
  x     db  0
data  ends
code segment
  assume cs:code,ds:data,ss:stack
main proc far
start:
  mov  ax,data
  mov  ds,ax
  
  mov  al,1ch
  mov  ah,35h
  int  21h
  push  es
  push  bx
  push  ds
  
  mov   dx,offset show_systime
  mov   ax,seg show_systime
  mov   ds,ax
  mov   al,1ch
  mov   ah,25h
  int   21h
  
  pop   ds
  in    al,21h
  and   al,11111110b
  out   21h,al
  
  sti
  mov   di,2000
delay:
  mov   si,3000
delay1:
  dec   si
  jnz   delay1 
  dec   di
  jnz   delay
  mov    ah,0
  int    16h
  pop  dx
  pop  ds
  mov  al,1ch
  mov  ah,25h
  int   21h
  
  mov   ah,4ch
  int  21h
main endp

show_systime proc near
   push  ds
   push  ax
   push  cx
   push  dx
   mov   ax,data
   mov   ds,ax
   sti
   dec count
   jnz  exit
   
   call   systime1
   mov  count,10
exit:
   cli
   pop   dx
   pop   cx
   pop   ax
   pop   ds
   iret
show_systime endp
   
systime1  proc  near  ;取系统时间
   push  bx
   push  ax
   push  cx
   push  dx
   pushf
   push  ds
   mov   ah,2ch
   int   21h
   
   mov   al,ch
   mov   x,71
   call  set_curisor
   call  bin_to_dex  ;时
   mov   dl,':'
   mov   ah,02h
   int   21h
   
   mov   al,cl
   add   x,3
   call  set_curisor
   call  bin_to_dex  ;分
   mov   dl,':'
   mov   ah,02h
   int   21h
   
   mov   al,dh   ;秒
   add   x,3
   call  set_curisor
   call  bin_to_dex 
   pop   ds
   popf 
   pop   dx
   pop   cx
   pop   ax
   pop   bx
   ret
systime1 endp

bin_to_dex proc near  ;数值转为10进制输出
   push  ax
   push  dx
   push  bx
   push  cx
   pushf
   xor   dx,dx
   cbw    ;al扩展为ax
   mov   bx,10
   div   bx
   mov   bx,dx  ;保存余数
   mov   dl,al
   add   dl,30h
   mov   ah,02h
   int   21h
   
   mov   dx,bx
   add   dl,30h
   mov   ah,02h
   int   21h
   popf
   pop  cx
   pop   bx
   pop   dx
   pop   ax
   ret
bin_to_dex  endp

set_curisor  proc near  ;置光标的位置


;在线等。。。。。。。。。。。
;等啊等


;谢谢!
   push  ax
   push  bx
   push  dx
   mov   bh,0
   mov   dh,24
   mov   dl,x
   mov   ah,2h
   int   10h
   pop   dx
   pop   bx
   pop   ax
   ret
set_curisor  endp

clear_screen  proc near
   push  ax
   push  bx
   push  cx
   push  dx
   mov   ah,6
   mov   al,0
   mov   bh,7
   mov   ch,0
   mov   ch,0
   mov   dh,24
   mov   dl,79
   int   10h
   pop   dx
   pop    cx
   pop   bx
   pop   ax
   ret
clear_screen endp;;;;;;;;;;;;;;;
code ends
end start

我来回复

您尚未登录,请登录后再回复。点此登录或注册