×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Delay/Sleep in assembly???

Delay/Sleep in assembly???

Delay/Sleep in assembly???

(OP)
hello

I am looking for any function/interrupt which can serve the purpose of sleep/delay in an assembly language program,

(as we use sleep() fuction in C language)

Looking for an early response...

s4shif

RE: Delay/Sleep in assembly???

Hi s4shif!

Look at Ralf Brown's Interrupt List:(INT 15,86 - WAIT)
------------------------------------------------------------
INT 15 - BIOS - WAIT (AT,PS)
    AH = 86h
    CX:DX = interval in microseconds
Return: CF clear if successful (wait interval elapsed)
    CF set on error or AH=83h wait already in progress
        AH = status (see #0422)
Note:    the resolution of the wait period is 977 microseconds on many systems
      because many BIOSes use the 1/1024 second fast interrupt from the AT
      real-time clock chip which is available on INT 70; because newer
      BIOSes may have much more precise timers available, it is not
      possible to use this function accurately for very short delays unless
      the precise behavior of the BIOS is known (or found through testing)
------------------------------------------------------------

Best Wishes...
OSProgrammer

RE: Delay/Sleep in assembly???

If you don't want to use interrupts, you can get second count from the CMOS. I wrote a program to show what I mean. It works, but the value in cx is about double the time in seconds.

assume cs:code

code segment
  org 100h
program:
  jmp start

  sec db ?

start:

  mov cx,0030h
  call timer

  mov ax,4c00h
  int 21h


; input: cx is value to delay for.
;        (approximate to seconds).
timer:
  sub bx,bx

  mov al,00h ; seconds address
  out 70h,al ; wake up port
  jmp $+2    ; a short delay
  in al,71h
  mov [sec],al

timer_loop:
  mov al,00h ; seconds address
  out 70h,al ; wake up port
  jmp $+2    ; a short delay
  in al,71h
  cmp al,[sec]
  je timer_loop
  ; second gone by...
  mov [sec],al
  inc bx
  cmp bx,cx
  jne timer_loop
  ret

code ends

end program


The mind is like a parachute - it works better when open...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close