home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / contrib / bcc2grx / src / delay.s < prev    next >
Encoding:
Text File  |  1993-04-07  |  1.1 KB  |  69 lines

  1. /*
  2.    BCC2GRX  -  Interfacing Borland based graphics programs to LIBGRX
  3.    Copyright (C) 1993  Hartmut Schirmer
  4.  
  5.    see bccgrx.c for details
  6.  
  7.  
  8.    Borland like delay() function
  9.  
  10.    The delay function is realized by
  11.    monitoring the hardware time and
  12.    the interrupt driven software timer.
  13.    No timer value is altered.
  14. */
  15.  
  16.     .globl  _delay
  17. _delay:
  18.     pushl   %ebp
  19.     movl    %esp,%ebp
  20.  
  21.     pushl   %ebx
  22.     push    %edx
  23.  
  24.     movl    8(%ebp),%edx
  25.     cmpl    $0, %edx
  26.     je      done
  27.  
  28.  
  29.     cli
  30.     movl    0xE000046A, %eax
  31.     movb    $4, %al
  32.     out     %al, $0x43
  33.     call    wait
  34.     inb     $0x40, %al
  35.     mov     %al, %bl
  36.     call    wait
  37.     inb     $0x40, %al
  38.     sti
  39.     movb    %al, %ah
  40.     movb    %bl, %al
  41.     notw    %ax
  42.  
  43.     imull   $19091,%edx,%edx
  44.     shr     $4, %edx
  45.     addl    %eax, %edx
  46.  
  47. loop:   cli
  48.     movl    0xE000046A, %eax
  49.     movb    $4, %al
  50.     out     %al, $0x43
  51.     call    wait
  52.     inb     $0x40, %al
  53.     movb    %al, %bl
  54.     call    wait
  55.     inb     $0x40, %al
  56.     sti
  57.     movb    %al, %ah
  58.     movb    %bl, %al
  59.     notw    %ax
  60.  
  61.     movl    %edx, %ebx
  62.     subl    %eax, %ebx
  63.     jae     loop
  64.  
  65. done:   popl    %edx
  66.     popl    %ebx
  67.     leave
  68. wait:   ret
  69.