home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / cpm / utils / asmutl / asmlib.lbr / DELAY.AZM / DELAY.ASM
Encoding:
Assembly Source File  |  1991-06-25  |  1.0 KB  |  44 lines

  1. ;----------------------------------------------------------------
  2. ; This is a module in the ASMLIB library.
  3. ;
  4. ;       Delay for the number of milliseconds in DE
  5. ;
  6. ;            Written         R.C.H.     16/8/83
  7. ;            Last Update    R.C.H.       22/10/83
  8. ;----------------------------------------------------------------
  9. ;
  10.     name    'delay'
  11. ;
  12.     public    delay
  13.     maclib    z80
  14. ;
  15. delay:
  16.     push    psw
  17.     push    d            ; save it
  18. delay2:
  19.     call    delay3
  20.     dcx    d            ; one less millisecond less overhead
  21.     mov    a,d
  22.     ora    e
  23.     jrnz    delay2            ; keep on till DE = 0
  24.     pop    d            ; restore users initial value
  25.     pop    psw
  26.     ret                ; back to user
  27. ;
  28. delay3:    ; delay 1 millisecond less the overhead involved in the above code.
  29. ;
  30. ; This routine must delay 3957 t-states
  31. ;
  32.     push    b            ; 11
  33.     mvi    b,230            ;  7
  34. delay4:    ; This loop does (4 + 13) * 230 - 5 = 3905 t
  35.     nop                ; 4
  36.     djnz    delay4            ; 13
  37. ; Fudge 14 machine cycles
  38.     in    0            ; 10
  39.     nop                ;  4
  40.     pop    b            ; 10
  41.     ret                ; 10
  42. ;
  43.     end
  44.