|
Reading the DOS timer
|
|
06-24-2010, 07:38 PM
Post: #1
|
|||
|
|||
|
Reading the DOS timer
Unless care is taken, TP/BP will access the longint DOS timer non-atomically, as two words. Therefore there is a chance (about once an hour) that it may be updated with an inter-word carry in between the two parts of a TP/BP access, which would lead to a one-hour error. Program ATOM046C.PAS demonstrates this (at an accelerated rate), when compiled by BP7 (but not TP5 ?!?).
Code: {$M 4000, 0, 0}32-bit Delphi does not have this problem; it does 32-bit accesses atomically. One way to access the DOS timer atomically is with Int1A/00 - but it was intended for OS use only, and does not itself update the DayCount when required; therefore the state of the Midnight Flag in Seg0040:$0070 will be lost. Code: Regs.AH := 0 ; Intr($1A, Regs) ;In Pascal, pseudo-atomic access can be done by (derived from postings by Franz Glaser and Osmo Ronkanen) :- Code: repeat T1 := MemL[Seg0040:$006C] until T1 = MemL[Seg0040:$006C] ;One might also force 32-bit access; but that requires better than the x86 instruction set, limiting its usefulness :- Code: function Tix : longint ; assembler ;See the current LONGCALC, at "Tix" and "Mls", for my present favorite Pascal and Delphi code; also NOWMINUS, which has Code: GetDate(Y, M, D, DoW) ;(in attachment). Original version of this very usefull and interesting theme for pascal programmers is here. Read rules ![]()
|
|||
|
06-24-2010, 07:40 PM
(This post was last modified: 06-24-2010 07:43 PM by l3g1sl4tor.)
Post: #2
|
|||
|
|||
|
RE: Reading the DOS timer
And TBH, I used this just once, I usually just use TIME DoS function (for getting time), but it is also handy to know how to manage with timer
Read rules ![]()
|
|||
|
06-26-2010, 06:07 AM
Post: #3
|
|||
|
|||
|
RE: Reading the DOS timer
Great job!
I'll save this for later use.
"Character is determined more by the lack of certain experiences than by those one has had." Friedrich Nietzsche |
|||
|
« Next Oldest | Next Newest »
|







I'll save this for later use.
