In: Computer Science
Microprocessor question
Q1:
Write a delay loop which produces a delay of 500 Microseconds on an8086 with a 5-MHz clock.?
Solution ;
Number of clock cycles for execution of the loop once (m) = 2 + 3 + 16 = 21
Time required for the execution of loop once = m X T = 21 X 1/(5 X 10^6) = 4.2 microseconds
Count = td/(m X T) = 500 X 10^-3 /(4.2 X 10^-6)
= 119048
By loading 119048 in BX, the time taken to execute the delay
program is approximately 500ms. The NOP included in the delay
program is to increase the execution time of the loop. To get more
delay, the number of NOP instructions in the delay loop can be
increased.
The MOV BX, Count & RET instructions in the delay program are executed only once. The JNZ instruction takes 16 T-states when the condition is satisfied (i.e. Z = 0) and four T - states when the condition is not satisfied, which occurs only once.
Exact delay = [4 x 0.1 + (2+3) x 119048 x 0.1 + 16 x 119047 x0.1
+ 4 X 0.1 + 8 X 0.1 ] micro seconds
= 0.4 + 28571.5 + 91427.2 + 0.4 + 0.8
= 250000.8 micro seconds
= 250.0008 ms
The error in the previous calculation is very less as the exact
delay is also very close to 500ms. When 16-bit count register is
used in the delay program, the maximum count value that can be
loaded in it is FFFFh. This may put a limitation on the maximum
time delay that can be generated using the above delay
subroutine.