Quote:

>Can anyone tell me if it is possible to access PC Watch (DOS Time)_

>directly through a memory location, something like:

> Time:word absolute $XXXX:$XXXX;

Var time:longint absolute $40:$6c

That is in clock ticks (about 55ms). Also TP does not guarantee atomic

access for longints so one should do something like:

repeat

t:=time;

until t=time;

If you just write some benchmarks then that does not matter. The chance

of corrupting interrupt occurring between the reads is about one in

trillion. Also it can only occurs on full hour. (For some coincidence(?)

the high word of the counter is updated almost exactly one a hour.

Using that has clock would give only 10 second error at the end of the

day.)

If you want seconds then multiply it by (24*3600/$1800B0)

Or if you prefer to use integers only then:

Function Ticks2Sec(ticks:longint):longint; assembler;

asm { uses ax,bx,dx,si,di }

mov bx,1080

mov ax,word ptr ticks

mul bx

mov si,ax

mov di,dx

mov ax,word ptr ticks+2

mul bx

add ax,di

mov dx,ax

mov ax,si

mov bx,19663*2

div bx { AX no of 2 second blocks 0..43199 }

cmp dx,19662

cmc

mov dx,0

adc ax,ax

adc dx,dx { DX:AX seconds (0..86399) }

End;

This loses the fraction information. Note that if one feeds higher

number of thicks than in 24 hours one can get RTE 200. Note the above is

accurate:

begin

Writeln(ticks2sec($1800B0));

Writeln(ticks2sec($1800B0-1));

end.

Outputs:

86400

86399

As you can see it uses truncation.

Quote:

>How can it be done in protected mode?

In protected mode you need to create pointer;

var timep:^longint;

....

timep:=Ptr(Seg0040,$6c);

then use timep^ instead of time. This of course works also in real

mode.

You can also use an assembler function:

function timer:longint; assembler;

asm

mov ax,es:[6ch]

mov dx,es:[6eh]

cmp ax,es:[6ch]

end;