哎...都没人回答
时间:2011-07-05
来源:互联网
原来发了个贴,没人回答,算了,再发个代码,各位帮助看看
biao MACRO ;biao宏用于对光标的控制,并读取当前光标前一位的字符
mov bh,0h
mov ah,3h
int 10h
sub dl,1h
mov ah,2h
int 10h
mov ah,8h
int 10h
endm
sum macro x,y
push ax
mov cl,4h
mov ah,0eh
cmp x,99h
jnz y
inc 1[&x]
y:
mov al,1[&x]
add al,30h
int 10h
mov al,x
add al,1h
daa
mov x,al
shr al,cl
add al,30h
int 10h
mov al,x
and al,0fh
add al,30h
int 10h
pop ax
endm
show macro x,y,z ;用来显示错误/正确提示,x为wrong/right
push dx
mov dx,1300h ;提示位置
mov ah,2h
int 10h
mov dx,offset x
mov ah,9h
int 21h
sum y,z ;调用sum宏指令,y为whit/rhit
mov dx,offset all ;显示总敲击提示
mov ah,9h
int 21h
call to ;显示总敲击次数
pop dx
mov ah,2h
int 10h
jmp bk
endm
DATAS SEGMENT
p db 0h,0h,0h ;用于存储打字开始时间
file db 'D:\masm\word.txt',0 ;文件位置,
dta db 250h dup(0),0dh,0ah,'$'
wrong db ' Hit Wrong! Number of Wrong Hits:$'
right db ' Hit Right. Number of Right Hits:$'
all db ' Total Hits:$'
sign db ' The Use of Time:$'
cur db ' The Current Time:$'
albuf db 0h ;对al的缓存
whit db 0h,0h
rhit db 0h,0h
total db 0h,0h
bsbuf db 0h
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
Start:
Main proc far
MOV AX,DATAS
MOV DS,AX
mov ah,2ch ;取打字开始时间
int 21h
mov p,ch ;存打字开始时间,p-小时,p+1-分钟,p+2-秒
mov 1[p],cl
mov 2[p],dh
mov ax,07h
int 10h
mov dx,offset file ;打开文件
mov ax,3d00h
int 21h
mov dx,offset dta ;读文件
mov cx,250h
mov bx,ax ;文件代号放入BX中
mov ah,3fh
int 21h
mov ah,9h ;显示文件内容
int 21h
D:
push ax
push dx
mov ah,08H ;循环录入
int 21H
cmp al,0dh ;Enter时跳转
jz calc
cmp al,08h ;处理BS的情况
jz bak
mov bsbuf,0h
pak:
mov dl,al
mov ah,02H
int 21H
call check ;检查是否打错字
next:
pop dx
pop ax
jmp D
bak:
cmp bsbuf,0h
jz bak1
jmp next
bak1:
mov bsbuf,1h
jmp pak
check proc near
push dx
push ax
biao
mov albuf,al
sub dh,9h ;找到对应字符,判断是否正确
mov ah,2h ;置光标在对比的字符处
int 10h
mov bh,0h
mov ah,8h ;读光标处字符
int 10h
add dh,9h ;返回光标
add dl,1h
mov ah,2h
int 10h
cmp albuf,al
jnz showwrong
jmp showright
bk:
pop ax
pop dx
ret
showwrong: ;用来显示错误/正确提示
show wrong,whit,lit1
showright: ;用来显示正确提示
show right,rhit,lit2
check endp
calc:
mov bh,0h ;存光标位置
mov ah,3h
int 10h
push dx ;光标信息入栈
mov bh,0h ;确定时间提示的位置
mov dx,1400h
mov ah,2h
int 10h
mov ah,2ch ;取Enter(结束)时间
int 21h
push dx
mov dx,offset cur ;将The Current Time显示出来
mov ah,9h
int 21h
pop dx
call time ;显示当前时间
sub ch,p ;计算打字所消耗的时间,默认系统24小时制
cmp cl,1[p] ;且打字时间不超过一天
jl bu1
pu1:
sub cl,1[p]
cmp dh,2[p]
jl bu2
pu2:
sub dh,2[p]
push dx
mov dx,offset sign ;将The Use of Time显示出来
mov ah,9h
int 21h
pop dx
call Time ;显示从开始到现在的时间长度
pop dx ;光标信息出栈
mov bh,0h ;返回光标
mov ah,2h
int 10h
jmp next
bu1: ;对分钟进行校正
sub ch,1h
add cl,3ch
jmp pu1
bu2: ;对秒进行校正
cmp cl,0h
jz bu3
sub cl,1h
add dh,3ch
jmp pu2
bu3: ;秒校正并消除对分钟产生的误差
mov cl,3bh
sub ch,1h
add dh,3ch
jmp pu2
to proc near ;计算并显示敲击键盘总次数
push ax
push cx
cmp total,99h
jnz hui
add 1[total],1h
hui:
mov al,1h
add al,total
daa
mov total,al
mov ah,0eh
mov ch,al
mov cl,4h
mov al,1[total]
add al,30h
int 10h ;以BIOS的10号中断进行显示输出
mov al,ch
shr al,cl
add al,30h
int 10h
mov al,ch
and al,0fh
add al,30h
int 10h
pop cx
pop ax
ret
to endp
Main endp
CODES ENDS
DATA1 SEGMENT
T db '00-00-00 $' ;时间格式
h db 0h,0h,0h
l db 0h,0h
lenth db 6h
DATA1 ENDS
CODE1 SEGMENT
ASSUME CS:CODE1,DS:DATA1
Time proc far
push ds
MOV AX,DATA1
MOV DS,AX
mov al,ch ;将小时送入convert
mov di,0h
call convert
mov al,cl ;将分钟送入convert
mov di,3h
call convert
mov al,dh ;将秒送入convert
mov di,6h
call convert
push dx
mov dx,offset T ;将时间显示出来
mov ah,9h
int 21h
pop dx
pop ds
ret
bcd proc near
mov bl,al ;al保存在bl中
and al,0f0h ;实现对al进行部分十进制化
mov h,al
shr al,cl
xor ah,ah
mul lenth
aam ;非压缩乘法十进制调整
shl ah,cl
mov 1[h],ah ;对al进行部分十进制化
mov l,al
and bl,0fh
cmp bl,09h ;通过比较来将al低位十进制化
ja R
Z: xor ah,ah
add al,bl
aaa ;非压缩加法十进制调整
shl ah,cl
mov 2[h],ah ;对al进行部分十进制化
mov 1[l],al
add al,h
add al,1[h] ;综合结果,得到al的BCD码
add al,2[h]
ret
R: ;处理al低四位大于09h的情况
add h,10h
add bl,06h
and bl,0fh
jmp Z
bcd endp
convert proc near ;将数字变为字符
push cx
push dx
mov cl,4h ;cl 作循环移位次数
call bcd
mov dl,al ;将al复制到dl中
shr al,cl ;将高位右移4位
add al,30h
mov T[di],al ;将时间信息存放在T数据块中
inc di
and dl,0fh
add dl,30h ;对时间进行字符化保存
mov T[di],dl
pop dx
pop cx
ret
convert endp
Time endp
CODE1 ENDS
END Start
biao MACRO ;biao宏用于对光标的控制,并读取当前光标前一位的字符
mov bh,0h
mov ah,3h
int 10h
sub dl,1h
mov ah,2h
int 10h
mov ah,8h
int 10h
endm
sum macro x,y
push ax
mov cl,4h
mov ah,0eh
cmp x,99h
jnz y
inc 1[&x]
y:
mov al,1[&x]
add al,30h
int 10h
mov al,x
add al,1h
daa
mov x,al
shr al,cl
add al,30h
int 10h
mov al,x
and al,0fh
add al,30h
int 10h
pop ax
endm
show macro x,y,z ;用来显示错误/正确提示,x为wrong/right
push dx
mov dx,1300h ;提示位置
mov ah,2h
int 10h
mov dx,offset x
mov ah,9h
int 21h
sum y,z ;调用sum宏指令,y为whit/rhit
mov dx,offset all ;显示总敲击提示
mov ah,9h
int 21h
call to ;显示总敲击次数
pop dx
mov ah,2h
int 10h
jmp bk
endm
DATAS SEGMENT
p db 0h,0h,0h ;用于存储打字开始时间
file db 'D:\masm\word.txt',0 ;文件位置,
dta db 250h dup(0),0dh,0ah,'$'
wrong db ' Hit Wrong! Number of Wrong Hits:$'
right db ' Hit Right. Number of Right Hits:$'
all db ' Total Hits:$'
sign db ' The Use of Time:$'
cur db ' The Current Time:$'
albuf db 0h ;对al的缓存
whit db 0h,0h
rhit db 0h,0h
total db 0h,0h
bsbuf db 0h
DATAS ENDS
CODES SEGMENT
ASSUME CS:CODES,DS:DATAS
Start:
Main proc far
MOV AX,DATAS
MOV DS,AX
mov ah,2ch ;取打字开始时间
int 21h
mov p,ch ;存打字开始时间,p-小时,p+1-分钟,p+2-秒
mov 1[p],cl
mov 2[p],dh
mov ax,07h
int 10h
mov dx,offset file ;打开文件
mov ax,3d00h
int 21h
mov dx,offset dta ;读文件
mov cx,250h
mov bx,ax ;文件代号放入BX中
mov ah,3fh
int 21h
mov ah,9h ;显示文件内容
int 21h
D:
push ax
push dx
mov ah,08H ;循环录入
int 21H
cmp al,0dh ;Enter时跳转
jz calc
cmp al,08h ;处理BS的情况
jz bak
mov bsbuf,0h
pak:
mov dl,al
mov ah,02H
int 21H
call check ;检查是否打错字
next:
pop dx
pop ax
jmp D
bak:
cmp bsbuf,0h
jz bak1
jmp next
bak1:
mov bsbuf,1h
jmp pak
check proc near
push dx
push ax
biao
mov albuf,al
sub dh,9h ;找到对应字符,判断是否正确
mov ah,2h ;置光标在对比的字符处
int 10h
mov bh,0h
mov ah,8h ;读光标处字符
int 10h
add dh,9h ;返回光标
add dl,1h
mov ah,2h
int 10h
cmp albuf,al
jnz showwrong
jmp showright
bk:
pop ax
pop dx
ret
showwrong: ;用来显示错误/正确提示
show wrong,whit,lit1
showright: ;用来显示正确提示
show right,rhit,lit2
check endp
calc:
mov bh,0h ;存光标位置
mov ah,3h
int 10h
push dx ;光标信息入栈
mov bh,0h ;确定时间提示的位置
mov dx,1400h
mov ah,2h
int 10h
mov ah,2ch ;取Enter(结束)时间
int 21h
push dx
mov dx,offset cur ;将The Current Time显示出来
mov ah,9h
int 21h
pop dx
call time ;显示当前时间
sub ch,p ;计算打字所消耗的时间,默认系统24小时制
cmp cl,1[p] ;且打字时间不超过一天
jl bu1
pu1:
sub cl,1[p]
cmp dh,2[p]
jl bu2
pu2:
sub dh,2[p]
push dx
mov dx,offset sign ;将The Use of Time显示出来
mov ah,9h
int 21h
pop dx
call Time ;显示从开始到现在的时间长度
pop dx ;光标信息出栈
mov bh,0h ;返回光标
mov ah,2h
int 10h
jmp next
bu1: ;对分钟进行校正
sub ch,1h
add cl,3ch
jmp pu1
bu2: ;对秒进行校正
cmp cl,0h
jz bu3
sub cl,1h
add dh,3ch
jmp pu2
bu3: ;秒校正并消除对分钟产生的误差
mov cl,3bh
sub ch,1h
add dh,3ch
jmp pu2
to proc near ;计算并显示敲击键盘总次数
push ax
push cx
cmp total,99h
jnz hui
add 1[total],1h
hui:
mov al,1h
add al,total
daa
mov total,al
mov ah,0eh
mov ch,al
mov cl,4h
mov al,1[total]
add al,30h
int 10h ;以BIOS的10号中断进行显示输出
mov al,ch
shr al,cl
add al,30h
int 10h
mov al,ch
and al,0fh
add al,30h
int 10h
pop cx
pop ax
ret
to endp
Main endp
CODES ENDS
DATA1 SEGMENT
T db '00-00-00 $' ;时间格式
h db 0h,0h,0h
l db 0h,0h
lenth db 6h
DATA1 ENDS
CODE1 SEGMENT
ASSUME CS:CODE1,DS:DATA1
Time proc far
push ds
MOV AX,DATA1
MOV DS,AX
mov al,ch ;将小时送入convert
mov di,0h
call convert
mov al,cl ;将分钟送入convert
mov di,3h
call convert
mov al,dh ;将秒送入convert
mov di,6h
call convert
push dx
mov dx,offset T ;将时间显示出来
mov ah,9h
int 21h
pop dx
pop ds
ret
bcd proc near
mov bl,al ;al保存在bl中
and al,0f0h ;实现对al进行部分十进制化
mov h,al
shr al,cl
xor ah,ah
mul lenth
aam ;非压缩乘法十进制调整
shl ah,cl
mov 1[h],ah ;对al进行部分十进制化
mov l,al
and bl,0fh
cmp bl,09h ;通过比较来将al低位十进制化
ja R
Z: xor ah,ah
add al,bl
aaa ;非压缩加法十进制调整
shl ah,cl
mov 2[h],ah ;对al进行部分十进制化
mov 1[l],al
add al,h
add al,1[h] ;综合结果,得到al的BCD码
add al,2[h]
ret
R: ;处理al低四位大于09h的情况
add h,10h
add bl,06h
and bl,0fh
jmp Z
bcd endp
convert proc near ;将数字变为字符
push cx
push dx
mov cl,4h ;cl 作循环移位次数
call bcd
mov dl,al ;将al复制到dl中
shr al,cl ;将高位右移4位
add al,30h
mov T[di],al ;将时间信息存放在T数据块中
inc di
and dl,0fh
add dl,30h ;对时间进行字符化保存
mov T[di],dl
pop dx
pop cx
ret
convert endp
Time endp
CODE1 ENDS
END Start
作者: s_evener 发布时间: 2011-07-05
这个代码有什么问题呢?
作者: WJN92 发布时间: 2011-07-05
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28