我有一个使用masm以汇编语言制作秒表的项目。秒表在程序启动时启动并继续。我想实现停止,暂停和播放等功能。我不能要求用户在秒表运行时输入任何值,因为它是一个循环,并且在每次迭代时,控制台上的文本每隔一毫秒更新一次。我认为在循环的每次迭代之前,我可以检查键盘缓冲区或类似的东西,这表示某个键被按下并使用该值来检测和停止,puase或播放秒表。我知道它不是真正的异步解决方案,但我找不到任何关于我在互联网上的问题的描述。
我的秒表守则:我想在做call clrscr
Include Irvine32.inc
.data
milisec dword 0
sec dword 0
min dword 0
milidiv dword 100
secdiv dword 60
colon byte " : " , 0
.code
main proc
PR :
call clrscr
mov eax, min
call WriteDec
mov edx, offset colon
call WriteString
mov eax , sec
call WriteDec
mov edx, offset colon
call WriteString
mov eax , milisec
call WriteDec
;mili= mili+1
mov eax, milisec
add eax,1
mov milisec , eax
mov edx , 0 ;storing value 0 to remove the garbadge value
div milidiv ;divide eax by 100 and getting the quotionet from edx
mov ebx , sec ;move the value of second in ebx
add eax, ebx ;now adding the previous value of second and the next quotiont value
mov edx , 0 ;storing value 0 to remove the garbadge value
div secdiv ;dividing the ebx by 60
mov sec, edx ;moving the quotiont from edx to second
mov eax, milisec ;moving milisec to eax
mov edx , 0
div milidiv ;dividde by mili
mov milisec, edx
mov eax,sec
mov edx , 0
div secdiv
add eax, min
mov min, eax
mov eax , 100
call Delay
jmp PR
exit
main endp
end main