INT 1Ah AH=00h returns the 32-bit tick count from 0040:006Ch: CX = high word, DX = low word. The timer interrupt adds 1 every 54.9 ms, and the count goes from 0 at midnight to 1 573 039 just before the next one. AL returns the "midnight passed" flag from 0040:0070h, and reading it clears it.

For timing short intervals the low word alone is enough: subtract the starting value and the 16-bit subtraction gives the right answer even across a wrap from FFFFh to 0. The example waits for 18 ticks, about one second, by watching the count:

prints: 18 ticks, about one second (after a pause of about a second)
MOV AH, 00h ; BIOS: read the tick count
INT 1Ah ; CX:DX = ticks since midnight
MOV BX, DX ; the low word is enough for short times
WAIT1:
MOV AH, 00h
INT 1Ah
MOV AX, DX
SUB AX, BX ; ticks gone by (wraps correctly)
CMP AX, 18 ; 18 ticks: about one second
JB WAIT1
CALL PDEC ; 18
MOV DX, OFFSET SEC1
MOV AH, 09h ; DOS: print the $-string at DS:DX
INT 21h
SEC1 DB " ticks, about one second", 13, 10, "$"
PDEC PROC NEAR ; print AX in decimal; keeps every register
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV BX, 10
XOR CX, CX ; digits on the stack
DECD1:
XOR DX, DX
DIV BX ; AX = AX / 10, DX = the last digit
PUSH DX
INC CX
TEST AX, AX
JNZ DECD1
DECD2:
POP DX ; the digits come back first to last
ADD DL, "0"
MOV AH, 02h
INT 21h
LOOP DECD2
POP DX
POP CX
POP BX
POP AX
RET
PDEC ENDP

Resolution

A tick is 55 ms, so anything measured in ticks is accurate to ±1 tick. For a delay of "at least n ticks" wait for n + 1, because the first tick may come right after you start. For finer timing programs read the timer chip's counter itself (port 40h, after latching it with port 43h), or use INT 15h AH=86h for a delay in microseconds.

Pitfalls

The midnight flag is meant for DOS: DOS reads it to know when to advance the date. A program that calls AH=00h itself around midnight can take the flag first, and on many DOS versions the date then fails to change. Programs that only want the count can read 0040:006Ch directly instead (with CLI around the two words, so a tick cannot fall between them). The count is reset at midnight, so a long measurement that crosses it sees time go backwards. AH=01h sets the count; it changes the system time, so leave it to DOS.