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

Control hazard and delayed branching, Described Instruction or control haza...

Described Instruction or control hazard? Ans: The pipeline can be stalled due to delay in the availability of an instruction. For instance, this may be a result of a miss in t

Give the example of first come first served scheduling, Consider  the  foll...

Consider  the  following set of jobs with  their  arrival  times,  execution  time  (in minutes), and deadlines. Job Ids Ar r ival Time E

What do you mean by digital computer, COMPUTER ORGANIZATION & ARCHITECTURE ...

COMPUTER ORGANIZATION & ARCHITECTURE 1. What do you mean by digital computer? Explain the block diagram of a digital computer. 2. What do you mean by Difference Engine? Expl

How can we pass selection and parameter data to a report, How can we pass s...

How can we pass selection and parameter data to a report? There are three options for passing selection and parameter data to the report. Using SUBMIT...WITH Using a rep

Determine the basic machine language instructions, Determine the basic Mach...

Determine the basic Machine language instructions Machine language instructions and data are in terms of 0s and 1s and are stored in the memory. It isn't possible to distinguis

Define electronic data interchange, Define Electronic Data Interchange. ...

Define Electronic Data Interchange. An EDI stand for Electronic Data Interchange is used by organizations for transactions which occur on regular basis to a pre-determined for

Determine the number of classes of ip addresses, The total number of class ...

The total number of class of IP address are? The total number of class of IP addresses are 5.

What is internal path length, Internal Path length It is described as t...

Internal Path length It is described as the number of node traversed while moving by one particular node to any other node in the tree.

What is looping, What is looping Loop is a control structure used to do...

What is looping Loop is a control structure used to do repetitive operation. Some programs include repeating a set of instruction either a particular number of times or until a

What are the events used for page headers and footers, What are the events ...

What are the events used for page headers and footers? The events TOP-OF-PAGE and END-OF-PAGE are used for pager headers and footers.

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