Solved

Time delay for 8086

Posted on 2003-12-05
2
11,604 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
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Array in beta 10 277
False Theorem 27 964
How to Building Five Part Assembly Name for Master Page Inherit 1 475
T-SQL and CLR parameter strings 9 25
Active Directory security has been a hot topic of late, and for good reason. With 90% of the world’s organization using this system to manage access to all parts of their IT infrastructure, knowing how to protect against threats and keep vulnerabil…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

749 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