汇编时钟的问题,求高手解答。。作业,急求
时间: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
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
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28