# Generate 1 minute and 2 minute delay using 8085 assembly language program

#### Soma Hota

Joined Feb 9, 2018
2
Can someone please help me with this 8085 assembly language program - Have to generate a delay of 1 minute and 2 min(separate programs) and frequency is 3Mhz. Have to do it using 16bit reg pair and the delay must be exact 60sec and 120sec. Have to show the delay generation calculation as well.
What I have done so far is this (1 minute delay generation):
Code:
Delay:
MVI D,00FFH 7 T states
L2:
LXI B,0B9BH 10 T states
L1:
DCX B 6 T states
MOV A,C 4 T states
ORA B 4 T states
JNZ L1 7/10 T states
DCR D 4 T states
JNZ L2 7/10 T states
RET 10 T states
Delay={(24*2971)+17}*0.33=0.02353sec
Now,I see this hint that 0.02353*255(FFh)=6.001sec and I want 60sec. I am not very good with assembly language as I am still learning but can someone please tell me what should I do here ? THANKS!!

Mod edit: code tags

Last edited by a moderator:

#### JohnInTX

Joined Jun 26, 2012
3,817
Hopefully this is just an exercise in instruction timings. Delay loops like this are not a good programming practice. That said here are some things to think about.

You can increase the time burned in the loop by using more instructions within the loop. The time burned in each instruction is effectively multiplied by the number of loops. Consider using some slow instructions for maximum effect. CALL, RETURN, PUSH, POP, XTHL (even number of times only!) are good cycle hogs.

Code:
Delay:
MVI D,00FFH 7 T states
L2:
LXI B,0B9BH 10 T states
L1:
CALL dummyRET  28Tstates per call+return  * Nloops

XTHL  32 Tstates each pair*Nloops
XTHL

PUSH PSW  22Tstates each pair*Nloops
POP   PSW

; counting section
DCX B 6 T states
MOV A,C 4 T states
ORA B 4 T states
JNZ L1 7/10 T states
DCR D 4 T states
JNZ L2 7/10 T states

NOP  trim with nops or other instructions with useful Tcyc count - could be part of dummyRET
NOP
dummyRET:
RET 10 T states
To keep things manageable, consider a loop that delays a little less than 1 sec or 100ms for example then call that loop Ntimes - the calls, returns and call counter make up the rest.
It is hard to make loop timing exact because of the time it takes to check those counters in BC and D. Make your loop something you can count easily if it fits the assignment.
Get the loop delay as close as possible then finish up with NOPs etc. in line to trim the time. Don't forget the 10 tcyc in the return.

I don't have much more to offer in terms of an exact approach. I don't use delays like this. The last time was, coincidentally, for a software UART on an 8085 and that's how I trimmed the loops. But the next revision used interrupt-driven timers (8252, 8155) and external UARTs (8251).

Maybe the point of the exercise is to point out why delays like this are a bad idea.

Good luck and welcome to AAC!

Last edited:

#### JohnInTX

Joined Jun 26, 2012
3,817
Delay={(24*2971)+17}*0.33=0.02353sec
Now,I see this hint that 0.02353*255(FFh)=6.001sec and I want 60sec.
Thinking on the scope of your problem after reading 'hint' plus re-evaluating what you mean by 'exactly' given that 6.001 sec. is not exactly 6.000 sec. maybe it just needs to be close.

You can run your original loop 10 times for ~60sec and 20 times for ~120sec by just loading the E register with 0ah or 14h respectively then running the main loop that many times using E as a counter. You could probably set it up to use DE as a counting pair as well. It won't be 'exact' but close. Probably fits more to the scope of the homework problem.