Calculation T-State in 8085

Calculation T-State in 8085

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.

Update (Answer):

I can help you calculate the total delay of this assembly code for the Intel 8085 microprocessor.

Here's a quick explanation on how to calculate the number of T-states, which are the internal clock pulses or ticks of the microprocessor:

  • MVI (Move Immediate) operation requires 7 T-states.

  • DCR (Decrement Register) operation requires 4 T-states.

  • JNZ (Jump if Not Zero) operation requires 7 T-states if the jump is taken, and 10 T-states if the jump is not taken.

  • RET (Return) operation requires 10 T-states.

Given this information, we can calculate the total delay of your code as follows:

  1. MVI C,0AH --> 7 T-states

  2. LOOP: MVI D,64H --> 7 T-states

  3. LOOP_5: MVI E,0DEH --> 7 T-states

  4. LOOP_6: DCR E --> 4 T-states

  5. JNZ LOOP_6 --> If zero flag is not set (i.e., E != 0 after decrement), the jump is taken, costing 7 T-states. This loop (LOOP_6) will execute 0DEH times, each time taking 11 (4+7) T-states.

  6. DCR D --> 4 T-states

  7. JNZ LOOP_5 --> This will execute 64H times, each time taking (4+7 for DCR and JNZ operations + 0DEH * 11 for the LOOP_6) T-states.

  8. DCR C --> 4 T-states

  9. JNZ LOOP --> This will execute 0AH times, each time taking (4+7 for DCR and JNZ operations + 64H ((4+7) + 0DEH 11) for LOOP_5) T-states.

  10. RET --> 10 T-states

So the total T-states will be:

1 (MVI C,0AH) 7 T-states + 1 (MVI D,64H) 7 T-states + 1 (MVI E,0DEH) 7 T-states + 0DEH (LOOP_6 executions) 11 T-states + 64H (LOOP_5 executions) (4 (DCR D) + 7 (JNZ LOOP_5) + 0DEH 11 (LOOP_6)) T-states + 0AH (LOOP executions) (4 (DCR C) + 7 (JNZ LOOP) + 64H (4 (DCR D) + 7 (JNZ LOOP_5) + 0DEH 11 (LOOP_6))) T-states + 1 (RET) 10 T-states

After simplifying the expression, you can calculate the total T-states for the delay code.

The result will be a measure of time delay. To convert this into a time measure like milliseconds, you would need to know the clock frequency of your 8085 microprocessor. The relation is simple: if you have the microprocessor's clock frequency, you can calculate the time of one T-state (it's the inverse of the clock frequency), then multiply the number of T-states by the time of one T-state to get the total time delay.

Replies

  • Abhishek Rawal
    Abhishek Rawal
    You need value of clock cycle or clock period to calculate delay.
  • vick5821
    vick5821
    clock period is 0.5us.

    Thanks
  • vick5821
    vick5821
    I am just very confuse on how I can calculate this kind of question systematically ><
  • Abhishek Rawal
    Abhishek Rawal
    Do you know how to calculate T-states ?
  • vick5821
    vick5821
    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
    Abhishek Rawal
    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
    vick5821
    I think I need a similar example for this is it ok ?

    I really get my brain cell accident >< LOL
  • Abhishek Rawal
    Abhishek Rawal
    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
    vick5821
    Thank you so much for the guide ! I will try to solve mine and see how it goes !

    Appreciate your help ๐Ÿ˜€
  • Abhishek Rawal
    Abhishek Rawal
    Pleasure,Free feel to explore CrazyEngineers.
    And hey! spread the word ๐Ÿ˜€
  • vick5821
    vick5821
    Still very confuse on how I can categorised it ><
    sigh
  • vick5821
    vick5821
    (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 !

You are reading an archived discussion.

Related Posts

Hey guys, what is the function of this low pass filter here ? Any details explanation for this ? Thanks !
I am keen in knowing physical meaning of poles and zeros. physical meaning in the sense what does poles and zeros mean in real world....
What are the machine(equipment) to make a 230voltage transformer. Reply please.....
How many of them like to go jobs or Business. Reply please.
I would like to inquire if we can have recombination in the collector of bipolar junction transistor? what about emitter? If not what could be the factors deterring this phenomenon?