EasyManua.ls Logo

Commodore PET - Page 295

Commodore PET
447 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
The PET also keeps track of time
in
"jiffies". A
"jiffy"
is
1/60
of a sec-
ond.
Reserved numeric variable
TIME.
or
TI.
is
a numeric variable which
is
auto-
matically incremented every
1/60
of a second. TIME
is
initialized to zero
on
start-
up.
and
is
reset back to zero after 51.839.999 jiffies. TIME$ (hhmmss)
is
a string
variable that
is
generated from
TIME.
To ensure greater accuracy the PET
keeps track of time
in
jiffies by incrementing every
1/60
of a second, instead
of once every second. When
TIME$
is
called to print the time
in
hours,
minutes, and seconds, the memory converts
jiffy
time to real time. Notice
that TIME$ and TI$
are
not the string conversion of TIME
and
TI
but
are
numbers
representing real time calculated from jiffy time
(TIME.
TI).
The conversion
is
done
as
follows.
Each
second
is
divided into 60 jiffies. One minute
is
composed of 60
seconds. One hour
is
made up of 60 minutes.
In
summary. one second
is
60 jiffies.
one minute
is
3600 jiffies. and one hour
is
216.000 jiffies.
as
illustrated below:
Jiffy
= 1
= 60 x
Jiffy
= 60 Jiffies
Minute
= 60 x Second
= 60 x (60 Jiffies)
= 3600 Jiffies
Hour
= 60 x
Minute
= 60 x (3600 Jiffies)
= 216.000 Jiffies
S,",\J;IIY
M;O"\S,,,Odl60
=
J;lIy
Hour/60 =
Minute/60
= Second/60 =
Jiffy
The following equations convert jiffy time
(J)
into real time divided into
hours
(Hl.
minutes (Ml. and seconds
(S).
We
can
write a program to print the time
from jiffies.
282
le
~T=TI
213
H=INT<J/216eee)
313
IF H<>e
THEN
J=J-H~2160e
41:::1
,..1=
l
NT
(.J
/3613(1)
513
IF
M<>e
THEN
J=J-M~36ee
Calculate hours.
Integer function takes only whole
number.
If any hours. subtract number of
jiffies in one hour by H to leave
remaining jiffies.
Calculate minutes.
Integer function takes only whole
number.
If any minutes. subtract number of
jiffies in minutes by 7 to leave
remaining jiffies.
Calculate seconds. Integer function
takes only whole number.

Table of Contents

Related product manuals