Time delay for 8086

I am writting an assembly program for 8086.I need to have a time delay which must be 1 sec.I thought something like that:

              NOP   ;(3 CYCLES)
              NOP   ;(3 CYCLES)
              NOP   ;(3 CYCLES)
              DEC BP  ;(2 CYCLES)
              JNZ AGAIN   ;(i am assuming it is 5 CYCLES)
              DEC DI
              JNZ AGAIN  

Is that code right?Will it be a delay of a second?

Is there any way to make this delay using the RTC clock of my PC?
LVL 23
Ioannis ParaskevopoulosAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It can be delay of one second. Maybe less, maybe more. It depends on your CPU speed.
The proper way is to read clock tickes with the help of INT 1Ah:
  MOV AH, 0
  INT 1Ah
  CX <- High clock word
  DX <- Low clock word
  For a second you need to count ~ 18 ticks

So code can be something like this:
  MOV DI, 18
  MOV AH, 0
  INT 1Ah
  MOV AH, 0
  INT 1Ah
  JA Delay

Note: You need to think about the case when "first" DX will be bigger than new one...

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bbaoIT ConsultantCommented:
yes, the right way to make delay is programing with RTC. see here for complete guide and source code in assembly:


hope it helps,
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.