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
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???
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???
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...