Use of delay loops, Computer Engineering

Assignment Help:

A very useful application of assembly is to generate delay loops. These loops are used for waiting for some time before execution of subsequent instruction.

However how to find time for the delay? The rate at which instructions are executed is determined by clock frequency. Every instruction occupies a certain number of clock cycles to execute. This multiplied by clock frequency of microprocessor gives actual time of execution of an instruction. For illustration MOV instruction occupies four clock cycles. This instruction when run on a microprocessor with a 4 MHz clock occupies 4/4 which means 1 microsecond. NOP is an instruction which is used to produce the delay without affecting actual running of program.

Time-delay of 1 ms on a microprocessor having a clock frequency of 5 MHz will necessitate:

1419_Use of delay loops.png

Thus, a 1-millisecond delay will require:

1588_Use of delay loops1.png

The subsequent program section can be used to produce the delay with counter value correctly initialised.

MOV CX, N    ; 4 clock cycles N will vary depending on

                        ; The amount of delay required

DELAY:         NOP                ; 3 cycles

                        NOP                ; 3 cycles

                        LOOP DELAY; 17 or 5

LOOP instruction occupies 17 clock cycles when condition is true and 5 clock cycles otherwise. Condition will be true 'N' number of times and false just once when control comes out of loop.

To calculate 'N':

  Total clock cycles    = clock cycles for MOV + N (2*NOP clock cycles + 17) - 12 (when CX = 0)

5000 = 4 + N (6 + 17) - 12 

 N = 5000/23 = 218 = 0DAh

So the counter CX must be initialized by 0DAh in order to get delay of 1 millisecond.


Related Discussions:- Use of delay loops

Vertical alignment of fields one below the other, Which Command permits for...

Which Command permits for vertical alignment of fields one below the other. UNDER Command is used ofr vertical alignment.

What is difference between hold time and setup, What is difference between ...

What is difference between hold time and setup? The interviewer was looking for one exact reason, and it’s really a good answer as well..The hint is hold time doesn't depend onto c

Avantages of oopl in a programming language, Object oriented programming la...

Object oriented programming languages directly show the real life objects. The features of OOPL as inheritance, polymorphism, and encapsulation makes it strong.

Artificial neural networks, Artificial Neural Networks: However imagin...

Artificial Neural Networks: However imagine now in this example as the inputs to our function were arrays of pixels and there actually taken from photographs of vehicles such

What is redefines clause, Redefines clause is used to permit the similar st...

Redefines clause is used to permit the similar storage allocation to be referenced by dissimilar data names.

What is the syntax of the assembler directive equ, The syntax of the assemb...

The syntax of the assembler directive EQU is ? Ans. The syntax of the assembler directive EQU is as given below: EQU

Difference between blocking and non-blocking, Difference between blocking a...

Difference between blocking and non-blocking Verilog  language  has  two  forms  of  the  procedural  assignment  statement:  blocking  and  nonblocking. The two are distinguis

Code segment , Specified  the code segment below and that n is the prob...

Specified  the code segment below and that n is the problem size, answer the following queries:   // . . . int sum = 0; if(x > 12){ for(int i = 1; i     for( i

Network, Give an intuitive explanation of why the maximum throughput, for s...

Give an intuitive explanation of why the maximum throughput, for small beta, is approximately the same for CSMA slotted Aloha and FCFS splitting with CSMA. Show the optimal expecte

How many precision resistors requires a weighted resistor, A weighted resis...

A weighted resistor digital to analog converter using N bits requires a total of ? Ans. Digital to analog converter, a weighted resistor using N bits needs a total of N precisi

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd