The 1989 2nd edition of the DOS PROGRAMMER'S REFERENCE says:
Midnight is determined as the number of ticks in a complete day of 86400 seconds (1573040 ticks of the clock, for a total elapsed time of 86399.9121 seconds). A flag byte in RAM is set to 1 when midnight passes, ...
The 1981 IBM 5150 Technical Reference manual shows next code on page A-77 (271/393):
INC TIMER_LOW
JNZ T4
INC TIMER_HIGH
T4:
CMP TIMER_HIGH, 018H
JNZ T5
CMP TIMER_LOW, 0B0H
JNZ T5
MOV TIMER_HIGH, 0
MOV TIMER_LOW, 0
MOV TIMER_OFL, 1
T5:
I have never given this a second thought before, but recently I ran a test on some of my older computers. I compiled next list:
BIOS | Year | TotalTicks |
---|---|---|
Award Modular BIOS v4.51 PG | 1996 | 1573040 |
Phoenix BIOS 4.00 Release 6.00 | 1999 | 1573041 |
Compaq System ROM 686P9 v1.11 | 2002 | 1573040 |
Phoenix Technologies LTD v1.23 | 2007 | 1573041 |
AMI BIOS | 2010 | 1573040 |
It appears that some BIOSes do add 1 extra tick to the count-of-day variable.
- Was this a wide-spread phenomena for which one should take precautions when creating algorithms that convert the tick count into the corresponding time, so as to avoid showing "24:00:00"?
- Is this phenomena limited to just the Phoenix BIOSes, and did they perhaps inject that +1 in order to avoid copyright infringements? See Davislor's answer on Why did IBM make the PC BIOS source code public?
The 2007 Phoenix Technologies BIOS uses next code:
add word [006Ch], 1
adc word [006Eh], 0
cmp word [006Eh], 24
jne T1
cmp word [006Ch], 00B1h
jne T1
xor ax, ax
mov [006Ch], ax
mov [006Eh], ax
inc byte [0070h]
T1:
Other than using 'better' assembly code, this snippet shows 2 differences from the original:
- 1800B1h instead of 1800B0h
- incrementing instead of setting the midnight flag