Solved

Time delay for 8086

Posted on 2003-12-05
2
10,675 Views
Last Modified: 2006-11-17
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:

AGAIN2:  MOV DI,01ADH
AGAIN:    MOV BP,FFFFH
              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?
0
Comment
2 Comments
 
LVL 11

Accepted Solution

by:
dimitry earned 500 total points
Comment Utility
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 BX, DX
Delay:
  MOV AH, 0
  INT 1Ah
  SUB DX, BX
  CMP DI, DX
  JA Delay

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

Expert Comment

by:Bing CISM / CISSP
Comment Utility
yes, the right way to make delay is programing with RTC. see here for complete guide and source code in assembly:

http://cs.smith.edu/~thiebaut/ArtOfAssembly/CH10/CH10-5.html

hope it helps,
bbao
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

In this article, you will read about the trends across the human resources departments for the upcoming year. Some of them include improving employee experience, adopting new technologies, using HR software to its full extent, and integrating artifi…
A procedure for exporting installed hotfix details of remote computers using powershell
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now