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

Explain potential of parallelism, Potential of Parallelism Problems in ...

Potential of Parallelism Problems in the actual world differ in respect of the amount of inherent parallelism intrinsic in respective problem domain. Some problems can be easil

Explain about cseg segment, CSEG SEGMENT  ASSUME CS:CSEG, DS:CSEG, SS:CS...

CSEG SEGMENT  ASSUME CS:CSEG, DS:CSEG, SS:CSEG  ORG 100h START:MOV AX, CSEG; Initialise data segment  MOV DS, AX; register using AX  MOV AL, NUM1; Take the first num

Differentiate between rom test and the ram test, Probelm : a) What is t...

Probelm : a) What is the purpose of "Jumps" in the 8051 Microcontroller? Describe three types of "Jumps". b) What is the purpose of a "call"? c) Differentiate between ROM

Explain different parameter passing mechanisms to a function, What are the ...

What are the different parameter passing mechanisms to a function? The different parameter-passing mechanisms are given below: 1.   Call by value 2.   Call by value-resu

What are the disadvantages of bespoke software, What are the disadvantages ...

What are the disadvantages of Bespoke Software -  Very dependent on suppliers of the software; if they go out of business there would be little or no support if problems occ

NETWORK ADMIN, Ask qDiscuss the risks of having a single root user and how ...

Ask qDiscuss the risks of having a single root user and how more limited management abilities can be given to others users on Linux/UNIX systems.uestion #Minimum 100 words accepted

Reprography of information distribution, Reprography In order to dissem...

Reprography In order to disseminate information widely some method of reprography is invariably used. Reprography is the science and practice of copying documents by photograph

What is serialization, What is serialization, how it works in .NET? Ser...

What is serialization, how it works in .NET? Serialization is when you persist the state of an object to a storage medium so an exact copy can be re-created at a later stage. S

Operating system, explain the various types of computer systems

explain the various types of computer systems

What is register set, What is Register Set Register Set:  Register set ...

What is Register Set Register Set:  Register set is used to keep immediate data during the implementation of instruction. This area of processor having of various registers.

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