Instruction manual

Time of Day Clock
and Calendar for the SYM·1
Now you can have a Clock and Calander running in your
SYM
at the same time you
are
running programs in
BASIC. The concepts presented can be easily generaliz·
ed
into other 'multi-task' operations.
Casmir J. Suchyta, III
and Paul
W.
Zitzewitz
Univ.
of
Michigan, Dearborn
4901
Evergreen Road
Dearborn, MI 48128
~
..
)
Here
is
a
machine
language
subroutine
for the
SYM-1
BASIC
which
keeps
track
of
time
and date while allow-
ing BASIC programs
to
be run.
A useful
adjunct
to
a microcom-
puter, especially one used in a system,
is a
continuously
running
clock
which
can be used to record the
time
at which
events
occur
or
to
generate signals
at
specified times. The
SYM·1
includes
timers on the 6522 VIA chips which make
implementation
of
such a clock easy.
The
clock
can be started, set, and read
from BASIC.
The clock is based on the use
of
the
6522
to
generate a train
of
accurately
spaced interrupts. The April, 1979, issue
of MICRO contained an article
by
John
Gieryic (page
31)
which presented the
techniques
of
setting
up and servicing
the interrupts. The
clock
is
an
adapta-
tion
of
those
techniques. The program
consists
of sections which set the clock,
initialize the interrupt, service the inter·
rupt, and
update
the clock. The clock-
calendar needs to be reset only on
February 29!
The program is loaded
into
the
highest bytes
of
available memory. On a
4K
machine
this
is
$OF54-$OFFF.
After
the program is loaded, BASIC is initializ-
ed
with
Memory Size set at 3920
to
avoid
overwriting the program. The clock is set
and started
by
the command PRINT
USR(3924,M,d,h,m),
where
the
four
parameters represent the month, date,
December, 1979
hour, and minute, respectively. The pro-
gram stores the times, then initializes
the interrupt and starts the timer as
described in MICRO 11:31. The
timer
located at $ACxx was used
to
avoid in-
terference
with
the
cassette
tape
routines. Once every 1/20 second an in·
terrupt
occurs
which is serviced
in
the
routines
starting
at
$OF90.
Accumulator
and registers are pushed on
to
the stack,
then the 1/20
of
seconds, seconds,
minutes, and hours are incremented as
needed. These four updates are done in
an indexed loop, using a table
of
com-
parison values
(20
fractions,
60
seconds,
60
minutes,
24
hours) stored at
$OFE9
to
see
if
the next timing unit should be in·
cremented. The days and
months
cannot
be
incremented in the same loop, and so
are done in the routines starting at
$OFBD.
There is a comparison table giv-
ing the number
of
days (plus one) in each
month
starting
at
$OFF4
used
to
deter-
mine
if
the
month
should
be in·
cremented. When all needed increments
are made the flag is cleared and the sav-
ed
registers pulled back from
the
stack.
The
clock
may
be
read from BASIC
by PEEKing at the appropriate storage
locations.
To
print the
date
and time in
the form 7/20/1979 17:45:02 execute the
commandPRINTPEEK(4083)"1"
PEEK(4082)"/1979
"PEEK(4081)":"PEEK(4080)":"PEEK·
(4079).
The number of the
month
in the
date
can be replaced by a three
letter
abo
breviation by using the following short
program
to
print
the date.
MICRO
--
The 6502 Journal
1 A$
=
"JANFEBMARAPRMAYJUN-
JULAUGSEPOCTNOVDEC"
2
MO
=1 + 3"(PEEK(4083)
-1)
3 PRINT
MID$(A$,MO,3);PEEK)4082);",1979"
Starting each program With
this
routine will let you know exactly when
you did each job. Another use
of
the
clock
is
to
serve as an alarm clock. You
may want the
SYM
to
turn on a light,
or
start
an experiment
at
a certain time. To
do
this
include a
tight
loop
which
in-
cludes
an
IF statement comparing one
or
more of the storage locations with the
desired time. When the comparison is
good, the loop will
be
exited and the
computer can execute the command.
.,.
f5~-Fff
r
F54
',c
H'
C,
E3
3:'
F1
n'
Eg,,-,,
I!F5C
63
8D
F2
t"!'"
f'l
E3
3D
F3,2!'"
Cr6i:
eF
6~
2t?
5f
8E
A9
9[
'3D,9C
c;
FfC
7::
A.f
Pc?
e'F
3D
7F
Af.
1'9,
D3
(;;F7Lt
ce
3DI'lF
AC
AI:
0D
A.C
29,69
r
F7
C E F 3 r
('
D
f'
C
?"
C
t?
gr· 0
S,
6 f
r!'!'"SlJ
P.C
A'J
51?
3D
0!;
AC
A9
C3dlf
0!'"'3C
'3r
1'5
AC
E0
t?3 4'3 8S'.
4'3,71'"
o F"94
93
LtcS
D'3
Ml
"'"
1'9
ee
99,19
rF9C
ED
0F
C'3
C~
Go
Fe
IS'.
I8,C4
('''"1'4
29
ED I'lF 69 01
D9
F8
e'F,1l3
0FAC
F0
FE
99
ED I'lF
f'9
C3
3D,
Ie
I'l
FELt
07
AC
68
1'.8
E8
AS'.
63
28,81
~FEC
Lt0 IS
AD
F2
0F
69
10'1
AE,91'"
o
FC4
F3
e'F
Dr:
F3
0!'"
Fe
Q'6
'30,fl3
0FCC
F2
I1!F
LtC
EI
Q'F
1'9
01
30,47
r FD/l
F2
0F
F'3
Fe
t?['
!'"t?
'If
,g
[,AI
t?FOC
F3
e'F
4C
EI
O'
f\:? t"1
'3Ed:'
I!FF4
FJ
rF
LtC
E1
0,
14
3C
3C,1A
e,EC
18
ec
05
IE
34
e'E
15
05>\1
rFF4
20
ID
2f1
IF
20
IF
2C
:?CdC
('!'"FC
IF
2t? I!'"
2e,3S'
Lt93!'
19:67