First post, by markot
In Turbo Pascal there is the divide error bug. On website are ways to fix it. But there is said the ticks 1193180 per second. When I tested this on some computers, a 10 second delay using the functions below gave only a 5 second delay.
On other website (http://www.delphigroups.info/2/d2/16758.html) I found out that following comment:
{ =========================================================== } { Wait specified number of 1.193180 MHz clock tics to elapse. } […]
{ =========================================================== }
{ Wait specified number of 1.193180 MHz clock tics to elapse. }
{ The system timer normally runs in mode 3, which counts down }
{ by twos, so Delay(1193180) may be only a half a second. }
{ =========================================================== }
Where could I find out more information about this thing? What is system timer "mode 3"?
http://mtech.dk/thomsen/program/pasbug.php
procedure ShortDelay(Interval: Word); assembler;{ Interval = number of ticksNote: About 1193180 ticks/s }asmpush axpush bxcmp Interval,0FFFFh { otherwise 0FFFFh will end in an infinite loop }jne @startdec Interval@start:in al,040h { save initial time in bx }mov bl,alin al,040hmov bh,al@delayloop:in al,040h { get current time }xchg al,ahin al,040hxchg al,ahsub ax,bx { calculate the difference }neg axcmp ax,Interval { are we done? }jb @delaylooppop bxpop axend;procedure delay(ms: Word);{ identical to the faulty Borland delay procedure }varA : Word;beginfor A := 1 to ms doShortDelay(1193); { pause for 1 ms }end;