Problem 8An
8085 microprocessor uses a 2MHz crystal. Find the time taken by it
to execute the following delay subroutine, including the CALL instruction
in the calling program.
DELAY:
PUSH PSW
MVI A,64H
DELAYLOOP:
NOP
DCR A
JNZ LOOP
POP PSW
RET
The CALL and RET
instructions each take 18 cycles of the system clock, PUSH and POP take
12 cycles each, and conditional jump takes 10 cycles if the jump is
taken and 7 cycles if is not. NOP takes 1 cycle. All other instructions
used above take (3 ý N + 1) clock cycles, where N is the number of accesses
to memory, not including the opcode fetch.
Answer 8
The various timings
are shown with the help of the following table:
| Instruction
|
Number of Cycles
|
Comments |
| CALL |
18
|
|
| PUSH |
12
|
|
| MVI A,64H |
4
|
3N + 1 where
N = 1 (one memory access) |
| NOP |
100
|
100 ý 1 cycle
each |
| DCR A |
100
|
100 ý 1 cycle
each |
| JNZ (taken) |
990
|
The loop is
executed 64H ý 1 = 99 times,
for a total of 99 ý 10 cycles. |
| JNZ (not taken) |
7
|
When the condition
is false |
| POP |
12
|
|
| RET |
18
|
|
|
Total:
|
1261
|
|
The 2MHz crystal
frequency is divided by 2 inside the 8085. Hence the operating frequency
is 1MHz, and the time for 1 cycle is 1 ýs.
The time for 1261
cycles is therefore 1261 ýs = 1.261 ms.
Contributor:
Naveen PN
03-02
|