CrazyEngineers Archive
Old, but evergreen and popular discussions on CrazyEngineers, presented to you in read-only mode.
@vick5821 • 25 May, 2013
DELAY_1: MVI C,0AH
LOOP: MVI D,64H
LOOP_5: MVI E,0DEH
LOOP_6: DCR E
JNZ LOOP_6
DCR D
JNZ LOOP_5
DCR C
JNZ LOOP
RET

How do I calculate for the total delay of this code ?

Anyone can help ?

Thanks ><

Pretty confused
@Abhishek Rawal • 25 May, 2013 You need value of clock cycle or clock period to calculate delay.
@vick5821 • 25 May, 2013 clock period is 0.5us.

Thanks
@vick5821 • 25 May, 2013 I am just very confuse on how I can calculate this kind of question systematically ><
@Abhishek Rawal • 25 May, 2013 Do you know how to calculate T-states ?
@vick5821 • 25 May, 2013 I know for a simple one. But still very confuse. Can you help me out ? Having an exam next week 😔

Thnaks and appreciate 😀
@Abhishek Rawal • 25 May, 2013 This program is quite simple.
You see first instruction ? That is counter 0A = 10 in decimal.
Now step by step execute the instruction & note how many times a instruction executes the loop until the number turns to zero.
Find total T-states & multiply it with clock period, You will get the answer.

The calculation of T-states don't have any specific step. It depends upon the program & it's logic.
In short I will say :
Find total number of T-states& multiply it with clock period & get the execution time.
In your case, The outer loop sets the multiplying count to the delay provided by the innermost loop. Though it seems tough it's quite easy.

If you still have problem, I will explain you with a similar example but I won't answer this specific question. You have to obtain answer on your own.
Sorry but that's where fun of logic lies, isn't it ? 😉
@vick5821 • 25 May, 2013 I think I need a similar example for this is it ok ?

I really get my brain cell accident >< LOL
@Abhishek Rawal • 25 May, 2013 Haha! Okay Here it is :

Consider the program (which is very similar to yours) :
MVI D,multiplier count (7T)
L2: MVI C, DelayCount (7T)
L1 : DCR C (4T)
JNZ L1 (10T or 7T)
DCR D (4T)
JNZ L2 (7T or 10T)
HLT

T-states I have mentioned on right side of instruction with round brackets.
Now calculations :
T-states for innermost loop : 7 + (delay count - 1) x 14 + 11
(*)T-states required for exe of program : (multiplier count - 1) x (T inner x 14) + 11

Delay count : 0Ah (10) & multiplier count 5h

Now you can easy calculate T inner : 7 + (10-1) x 14 + 11 = (Something something)
Now put this value of T-states obtained in equation (*) & then multiply with clock period & you'll get the time required for executing the program 😀

This is mere logic. Please note that there is no ideal method to calculate time delay for x-y-z program.
The easiest thing to keep in mind is : Understand the program, calculate total T-states keeping no. of loops in mind & multiply it with clock period.

I guess this helps 😀
@vick5821 • 25 May, 2013 Thank you so much for the guide ! I will try to solve mine and see how it goes !

Appreciate your help 😀
@Abhishek Rawal • 25 May, 2013 Pleasure,Free feel to explore CrazyEngineers.
And hey! spread the word 😀
@vick5821 • 25 May, 2013 Still very confuse on how I can categorised it ><
sigh
@vick5821 • 26 May, 2013 (multiplier count - 1) x (T inner x 14) + 11,

I do not understand this equation. (T inner x14) <--- very confuse for this .. Which part is it ?

Thanks !
10.6k views

Related Posts

@Kaustubh Katdare · Feb 6, 2011

A Screw & Bolt is an integral part of every engineer's toolkit. Every hobby engineer needs them as well. Here's a simpler chart that gives you a quick view of...
2k views

@Mayur Pathak · Aug 28, 2008

4 criminals are caught and are to be punished. The Judge allows them to be freed if they can solve a puzzle. If they do not, they will be hung....
30k views

@Akhilesh Garud · Jul 5, 2014

The Indian market has turned into playground for almost all the smartphone manufacturing companies. One such company- Xolo, recently launched the Q 500s IPS by giving it a price tag...
4.3k views

@Chirayu Samarth · Mar 24, 2015

The Chinese manufacturer, Lenovo has launched a new budget phablet named- Lenovo K3 Note in China. The phablet is priced at CNY 899 (approximately Rs. 9,000) and will be available...
2.1k views

@swaroop2003 · Dec 7, 2008

hi , i am doing third year mechanical. there is a mini project this year... so anyone can help me out with ideas😕
6.3k views