sleep function ?

How to write a sleep procedure thet waits a number of miliseconds(it's not necesary at milisecond level).I heard that you have to read the clock or use int 1Ch but i have no ideea how to do this.
Can someone help me ?
10x

Comments

  • : How to write a sleep procedure thet waits a number of miliseconds(it's not necesary at milisecond level).I heard that you have to read the clock or use int 1Ch but i have no ideea how to do this.
    : Can someone help me ?
    : 10x
    :

    grab this:
    http://www.programmersheaven.com/search/download.asp?FileID=1481

    This is a huge document describing every possible way to do timing stuff in assembly, from ultra tiny uS delays on up.

    It includes plenty of source code and other snippets too. I'm sure it'll come in handy for this and future projects.

    -jeff!

  • : How to write a sleep procedure thet waits a number of miliseconds(it's not necesary at milisecond level).I heard that you have to read the clock or use int 1Ch but i have no ideea how to do this.
    : Can someone help me ?
    : 10x
    :
    I made a timer using the vertical retrace, which works fine for dos etc.
    Let me know if you want it.

    \\||////
    @)
    ASHLEY4.
  • : : How to write a sleep procedure thet waits a number of miliseconds(it's not necesary at milisecond level).I heard that you have to read the clock or use int 1Ch but i have no ideea how to do this.
    : : Can someone help me ?
    : : 10x
    : :
    : I made a timer using the vertical retrace, which works fine for dos etc.
    : Let me know if you want it.
    :
    : \\||////
    @)
    : ASHLEY4.
    :
    I would like to know about vertical retrace .
    10x for yuor answers
  • [b][red]This message was edited by ASHLEY4 at 2004-8-31 6:41:48[/red][/b][hr]
    This is the code for the vertical retrace delay:
    [code]
    ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;
    ; This give's a delay.
    ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::;

    FullVertWait:
    mov dx,3dah
    vr:
    in al,dx
    test al,8
    jnz vr ; wait until Vertical Retrace starts
    nvr:
    in al,dx
    test al,8
    jz nvr ; wait until Vertical Retrace Ends
    add word[count1],1
    ret
    Delay:
    mov word[count1],0
    ddf:
    call FullVertWait
    cmp word [count1],700 ; 70 = 1 second,so this = 10 seconds
    jne ddf
    ret

    count1 dw 0

    [/code]

    By calling, "call DeLay", the code above with delay 10 seconds, this uses the monitor's, refresh rate ( for a 70Hz monitor = 70 times a second ).
    So each time the monitor refresher's it at add's 1 to the "count1" var, so by the time it gets to 700 it should be 10 second.
    So for a delay of a second,it would be "cmp word[count1],70".

    Most monitor in dos are about 70Hz, some very old one may 50Hz.
    The code is for assembling with fasm/nasm?.

    Note: This code work's in text and graphic mode.

    \\||////
    @)
    ASHLEY4.

  • : How to write a sleep procedure thet waits a number of miliseconds(it's not necesary at milisecond level).I heard that you have to read the clock or use int 1Ch but i have no ideea how to do this.
    : Can someone help me ?
    : 10x
    :

    If you don't have the interrupt list, you need to get it. There a lot
    of functions that'll even do LFN stuff.

    Here is code for two ways of doing delays, one being a lot more precise depending on what you need.

    ; 86h.asm Pause 5 seconds and then display message
    ; Use function 83h to do something during
    ; the time interval
    ;
    ; INT 15h, 86h (134) Wait XT-286, AT
    ;
    ; Waits a specified number of microseconds before returning control to
    ; the caller.
    ;
    ; On entry: AH 86h
    ; CX:DX Number of microseconds to elapse
    ;
    ; Returns: Carry Set if error or wait in progress, else
    ; cleared
    ;
    ; Notes: This service is not available for the PC, PCjr, and
    ; the XT.
    ;
    ; The real-time clock is used to count the number of
    ; microseconds.
    ;
    ; The granularity of the time is 976 microseconds. (1/1000 second)
    ; 1,000,000 microseconds = 1 second
    ;
    ; CX is the high-order word of the count. For example,
    ; if CX is 98h (152d) and DX is 9680h (38528d), a 10-second delay
    ; would be specified.
    ;

    .model small
    .stack 200h

    include macros.as

    .data
    start_message db 'Bios timer started.','$'
    finish_message db 'Delay finished.','$'

    .code

    start:
    mov ax,@data
    mov ds,ax
    clr_scr
    mov dx,offset start_message
    mov ah,9
    int 21h
    ; 5 second delay (5,000,000 microseconds)
    mov ax, 10000 ; place a 10000 decimal in ax
    mov dx, 500 ; place 500 decimal in dx
    mul dx ; multiply ax times dx and place
    mov cx,dx ; the 32 bit product in dx:ax (lower 16 bits in ax)
    mov dx,ax
    xor ax,ax
    mov ah,83h
    int 15h
    clr_scr
    mov dx,offset finish_message
    mov ah,9
    int 21h
    exit:
    mov ax,4c00h
    int 21h

    end start

    ; delay.asm Precise clocked program delay (Same delay using any CPU)
    ; Andrew Kennedy 5/1995
    ; Bios clock has a pulse rate of 18.2 times/second
    ; 18.2 x 5 seconds = 91 Useful for delays UNDER 14 seconds.
    ; .5 second = 9.1 pulses
    ; .1 second = 1.8
    ; .05 second = 1
    ;
    ; The lowest two bytes can time up to 59 mins 59 secs.

    .model small
    .stack 200h ; 512 byte stack
    .data

    string db 'Timer tick tocking...','$'

    .code

    start:
    mov ax,@data
    mov ds,ax
    lea dx,string
    mov ah,9
    int 21h
    mov ah,0 ; function no. for read
    int 1ah ; get the time of day count
    add dx,9 ; add one half second delay to low word
    mov bx,dx ; store end of delay value in bx
    again:
    int 1ah
    cmp dx,bx
    jne again
    exit:
    mov ax,4c00h
    int 21h

    end start

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories