8155/8156/8155-2/8156-2
EXAMPLE PROGRAM
Following
is
an actual sequence
of
program steps that adjusts the 8155/56 count register
contents to obtain the count, extracted from
Intel@
Application Note AP38. "Application
Techniques for the Intel8085A Bus." First store the value
of
the full original count in register
HL
of
the 8085A. Then stop the
count
to
avoid getting an incorrect
count
value. Then sample
the timer-counter, storing the lower-order byte of the current
count
register in register C and
the higher-order
count
byte in register
B.
Then, call the following 8080A/8085A subroutine:
ADJUST,78
MOV A,B
E63F
ANI3F
1F
RAR
47
MOV B,A
79
MOV A,C
1F
RAR
4F
MOV C,A
00
RNC
3F
CMC
7C
MOV A,H
1F
RAR
67
MOV H,A
70
MOV A,L
1F
RAR
6F
MOV L,A
09 DAD B
44
MOV B,H
40
MOV C,L
C9 RET
;Load accumulator with upper half
;
of
count.
;Reset upper 2 bits and clear carry.
;Rotate
right
through carry.
;Store shifted value back in
B.
;Load accumulator with lower half.
;Rotate right through carry.
;Store lower byte in
C.
;If in 2nd half
of
count, return.
;If in 1st lialf, go on.
;Clear carry.
;Divide
full
count
by
2.
(If HL
;is odd, disregard remainder.)
;Double-precision add HL and BC.
;Store results back in BC.
;Return.
After executing the subroutine, BC
will contain the remaining
count
in the current
count
cycle.
6-89