• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 12960
  • Last Modified:

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:

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
Ioannis Paraskevopoulos
Asked:
Ioannis Paraskevopoulos
1 Solution
 
dimitryCommented:
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
 
bbaoIT ConsultantCommented:
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Tackle projects and never again get stuck behind a technical roadblock.
Join Now