+ -
当前位置:首页 → 问答吧 → 汇编时钟的问题,求高手解答。。作业,急求

汇编时钟的问题,求高手解答。。作业,急求

时间:2011-11-24

来源:互联网

data segment
  intro db 'S=start, Space=stop, Esc=turn off the window',10,13
  str1 db 'The date is',20h
  str2 db 4 dup(0),'/'
  str3 db 2 dup(0),'/'
  str4 db 2 dup(0),10,13
  timeshow db 'The time is ',10,13
  tenhour db 30h
  hour db 30h,':'
  tenminute db 30h
  minute db 30h,':'
  tensecond db 30h
  second db 30h,'$'
  year dw 0
  month db 0
  day db 0
data ends
stack segment 'stack'
  db 256 dup(0)
stack ends
code segment public
  assume cs:code,ds:data,ss:stack,es:data
start: jmp begin
num2asc proc
  mov si,10
  mov cx,4
  next: xor dx,dx
  div si
  add dx,'0'
  dec bx
  mov [bx],dl
  dec cx
  jnz next
  ret
num2asc endp
num2asc2 proc
  mov si,10
  mov cx,2
  next2: xor dx,dx
  div si
  add dx,'0'
  dec bx
  mov [bx],dl
  dec cx
  jnz next2
  ret
num2asc2 endp
begin: mov ax,data
  mov ds,ax
  mov ah,2ah
  int 21h
  mov word ptr year,cx
  mov byte ptr month,dh
  mov byte ptr day,dl
  mov bx,offset str2+4
  xor ax,ax
  mov ax,word ptr year
  call num2asc
  mov bx,offset str3+2
  xor ax,ax
  mov al,byte ptr month
  call num2asc2
  mov bx,offset str4+2
  xor ax,ax
  mov al,byte ptr day
  call num2asc2
  mov dx,offset intro
  mov ah,09h
  int 21h
  mov ah,2ch
  int 21h
search: mov ah,1
  int 16h
  jnz search
  mov ah,0
  int 16h
  cmp al,73h
  je timer
  cmp al,1bh
  je stop
  jmp search
timer: push dx
inc second
cmp second,'9'
jle timerx
mov second,'0'
inc tensecond
  cmp tensecond,'6'
  jl timerx
  mov tensecond,'0'
  inc minute
  cmp minute,'9'
  jle timerx
  mov minute,'0'
  inc tenminute
  cmp tenminute,'6'
  jl timerx
  mov tenminute,'0'
  inc hour
  cmp hour,'9'
  ja adjhour
  cmp hour,'3'
  jnz timerx
  cmp tenhour,'1'
  jnz timerx
  mov hour,'1'
  mov tenhour,'0'
timerx: mov dl,13
mov ah,02h
int 21h
mov dx,offset tenhour
mov ah,09h
int 21h
mov ah,1
  int 16h
  mov ah,0
  int 16h
  cmp al,1bh
  je stop
  cmp al,20h
  je timerx
  jmp judge
adjhour: inc tenhour
mov hour,'0'
judge: mov ah,2ch
  int 21h
  mov al,dh
  pop bx
  cmp al,bh
  jne timer
  je judge
stop: mov ah,4ch
  int 21h
code ends
end start

作者: danielinwind   发布时间: 2011-11-24

这个程序在计时的时候速度特别快,貌似是在比较秒钟有无变化时存在问题,但是不知道怎么改。。

作者: danielinwind   发布时间: 2011-11-24