Question

I am trying to design a stopwatch program on assembly using M/Tasm syntax as my own personal project that first displays the system time and prints it and then later on act as a stopwatch, (starts at 00:00:00). If the user presses 's' at runtime, the program will show the hh:mm:ss passed since the stopwatch was started and then display the result. I have successfully designed the code to get system time, display it, and execute a proper stopwatch. Problem is I can't manage to stop my stopwatch at runtime and then display the time passed in hh:mm:ss. Anyone with any ideas? I can't paste my code here on SO or else my code will be used by others, It is a long code, Please understand, that I have my reasons for this :).

Thank You.. just asking for ideas, not the code :)

Was it helpful?

Solution

It a shame you can't post your code, but I presume that you're using some kind of loop for updating the stopwatch and thus have some kind of code like;

loop:
"update stopwatch"
JMP loop

and you what to quit the loop when 's' is pressed. If that is the case you can query the keyboard status to see if the key is pressed.

loop:
"update stopwatch"
MOV AH, 0x01
INT 0x16
JZ loop     ; ZF is set if there is no key in buffer
MOV AH, 0x00
INT 0x16    ; Get ASCII code from buffer
CMP AL, "s"
JNE loop

Probably not the most elegant way, but it should work.

I hope this answers your question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top