Assembly program to stop stopwatch counter if a key is pressed and show the stopwatch count-Collection of common programming errors

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.