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 management information base variables, Explain MIB (Management Info...

Explain MIB (Management Information Base) variables. MIB is a set of named items which an SNMP agent knows. To control or monitor a remote computer, a manager should fetch or s

What is arrays pointers, Q. What is Arrays Pointers? An array is a coll...

Q. What is Arrays Pointers? An array is a collection of similar type of data. Arrays are extremely popular data structures in parallel programming because of their easiness of

How do you debug a loadrunner script, VuGen have two options to help debug ...

VuGen have two options to help debug Vuser scripts-the Run Step by Step command and breakpoints. The Debug settings in the Options dialog box permit us to verify the extent of the

Example of blocking probability for the three stage network, A three stage ...

A three stage network is realized by using switching matrices of size p x s in stage 1, r x r matrices in stage 2 and s x p matrices in stage 3. Using the Lee's probability graph s

How to create a new object order preference, 1. In an ASCII editor, make an...

1. In an ASCII editor, make an empty text file with the extension .ord. 2. Save the file in the Dat folder of the project. 3. Click To o l s > G UI R e c o r d O p t i o n s

Prepare a decision tree, A part of an aircraft engine can be given a test b...

A part of an aircraft engine can be given a test before installation.  The test has a 75% chance of revealing a defect if it is present, and the same chance of passing a sound part

Features added in message passing interface-2, Q. Show the Features added i...

Q. Show the Features added in message passing interface-2 Input/output Single-sided operations for remote memory access Binding for C++ Dynamic process managem

Explain the working of any one of centralized spc, Explain the working of a...

Explain the working of any one of centralized SPC? Standby mode of operation is the easiest of dual processor configuration operations. Usually, one processor is active and

Explain the working of hundred-line exchange, In a hundred-line exchange 24...

In a hundred-line exchange 24 two-motion selectors are used. Draw the schematic you suggest for this exchange and explain its working. How many simultaneous calls can be made durin

Differences between flexgrid control and dbgrid control, Normal 0 ...

Normal 0 false false false EN-IN X-NONE X-NONE MicrosoftInternetExplorer4

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