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 ticks
Note: About 1193180 ticks/s }
asm
push ax
push bx
cmp Interval,0FFFFh { otherwise 0FFFFh will end in an infinite loop }
jne @start
dec Interval
@start:
in al,040h { save initial time in bx }
mov bl,al
in al,040h
mov bh,al
@delayloop:
in al,040h { get current time }
xchg al,ah
in al,040h
xchg al,ah
sub ax,bx { calculate the difference }
neg ax
cmp ax,Interval { are we done? }
jb @delayloop
pop bx
pop ax
end;
procedure delay(ms: Word);
{ identical to the faulty Borland delay procedure }
var
A : Word;
begin
for A := 1 to ms do
ShortDelay(1193); { pause for 1 ms }
end;