Write a delay function in assembly using NOP that takes 1mse
Write a delay function in assembly, using NOP that takes 1msec to complete.
Solution
using 8051 microcontroller
1 machine cycle will have 1.085us execution time
mov ro,#230 ; 1 machine cycle * 1
loop1: nop ; 1 machine cycle * 230
nop ; 1 machine cycle * 230
djnz r0,loop1 ; 2 machine cycle * 230
result : total machine cycles = 4 * 230 + 1 = 921
so generated delay = 921 * 1.085us
= 1ms
