?
Solved

Time delay for 8086

Posted on 2003-12-05
2
Medium Priority
?
12,237 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
dimitry earned 1500 total points
ID: 9883531
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:bbao
ID: 9893127
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

771 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