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:
MOV AH, 00h ; BIOS: read the tick countINT 1Ah ; CX:DX = ticks since midnightMOV BX, DX ; the low word is enough for short timesWAIT1:MOV AH, 00hINT 1AhMOV AX, DXSUB AX, BX ; ticks gone by (wraps correctly)CMP AX, 18 ; 18 ticks: about one secondJB WAIT1CALL PDEC ; 18MOV DX, OFFSET SEC1MOV AH, 09h ; DOS: print the $-string at DS:DXINT 21hSEC1 DB " ticks, about one second", 13, 10, "$"PDEC PROC NEAR ; print AX in decimal; keeps every registerPUSH AXPUSH BXPUSH CXPUSH DXMOV BX, 10XOR CX, CX ; digits on the stackDECD1:XOR DX, DXDIV BX ; AX = AX / 10, DX = the last digitPUSH DXINC CXTEST AX, AXJNZ DECD1DECD2:POP DX ; the digits come back first to lastADD DL, "0"MOV AH, 02hINT 21hLOOP DECD2POP DXPOP CXPOP BXPOP AXRETPDEC 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.