Solved

Time delay for 8086

Posted on 2003-12-05
2
11,035 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
i have matlab code  i want to  convert it to VHDL  code  how  ??? 2 1,039
Books on the Windbg debugger? 3 1,341
How to diplay the real thread ID 21 1,172
memory mapped I/O query 6 147
For months I had no idea how to 'discover' the IP address of the other end of a link (without asking someone who knows), and it drove me batty. Think about it. You can't use Cisco Discovery Protocol (CDP) because it's not implemented on the ASAs.…
An article on effective troubleshooting
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

772 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