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

Which loader is executed when a system is first turned on, Which loader is ...

Which loader is executed when a system is first turned on or restarted? Ans. Bootstrap loader executed while a system is first turned on or restarted.

Explain an interrupt, Used to interrupt CPU normal implementation routine a...

Used to interrupt CPU normal implementation routine and to get its attention .Mostly generated by an external devices, timers, counters...etc

What is the principle of locality, What is "the principle of locality"? ...

What is "the principle of locality"? It's the nature of the processes that they refer only to the small subset of the total data space of the process. I.e. the process frequ

What is cursor, The illustration of the mouse on-screen. Depending on your ...

The illustration of the mouse on-screen. Depending on your settings, the cursor can be many dissimilar things.

What are the touch panels, What are the Touch Panels In case of touch p...

What are the Touch Panels In case of touch panels, displayed objects or screen positions is allowed to be selected with the touch of a finger. A typical application of touch pa

Computer systems architecture, Assume that you are working in a software co...

Assume that you are working in a software company as a programmer and a bank is your company's client. The Bank is a most popular and one of the leading banks in Malaysia. Your

What do you mean by communication traffic, Q. What do you mean by Communica...

Q. What do you mean by Communication Traffic? Communication Traffic offers a pictorial view of communication traffic in interconnection network with respect to time in progress

Determine the nand gate, Find out the two inputs when the NAND gate output ...

Find out the two inputs when the NAND gate output will be low. Ans. The output of NAND gate will be low if the two inputs are 11. The Truth Table of NAND gate is shown

List the properties which a hashing function should possess, List the prope...

List the properties which a hashing function should possess to ensure a good search performance. What approaches are adopted to handle collision? A hashing function h must poss

Calculate traffic offered in erlangs in a particular exchang, In a particul...

In a particular exchange during busy hour 1200 calls were offered to a group of trunks, during this time 6 calls were lost. The average call duration being 3 minutes Calculate Traf

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