home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / asm / MISC_ASM.ZIP / BEEP03.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-02-28  |  2.3 KB  |  88 lines

  1.     page    ,132
  2.     title    Batch file Beep
  3.  
  4. ;------------------------------------------------------------------------
  5. ;
  6. ;  Beep      -    Bill Gibson - 1987
  7. ;        Lathrup Village, Mi 48076
  8. ;
  9. ;   Ver. 1.01 -  sound using ASCII character 7            -    02/26/87
  10. ;     1.02 -  using the 8253 timer chip directly        -    02/26/87
  11. ; *     1.03 -  now a siren (a mod of v1.02)            -    02/28/87
  12. ;
  13. ;  For Public Domain Use.  Not for Sale or Hire.
  14. ;------------------------------------------------------------------------
  15. COMMENT *
  16.        As requested by Viggo Jensen.
  17.  
  18.    Beep utility - sounds alarm until any key is pressed.
  19.  
  20.           Obviously, best use of this small utility is at
  21.           the end of a batch file.  Could be used to replace
  22.           the DOS "pause" command.
  23. *
  24. ;------------------------------------------------------------------------
  25. code        SEGMENT BYTE PUBLIC 'code'
  26. ASSUME        CS:code,DS:code,SS:code
  27.  
  28.         ORG    100h
  29.  
  30. Beep        PROC    FAR
  31.  
  32.         CALL    Sound        ;sound the horn
  33. exit:
  34.         MOV    AH,4Ch
  35.         INT    21h
  36.  
  37. ;------------------------------------------------------------------------
  38. ; Work Area - constants,equates,messages
  39. ;------------------------------------------------------------------------
  40. cr        EQU    0Dh        ;carriage return
  41. lf        EQU    0Ah        ;line feed
  42. esc        EQU    01Bh        ;escape char
  43.  
  44. msg1        DB    cr,lf,'Beeping - press any key to quit...','$'
  45.  
  46. ;--------------------------------------------------------------------------
  47. ; Sub-Routines: Declare each Proc PUBLIC for use with MapSym & SymDeb v4.0
  48. ;--------------------------------------------------------------------------
  49.         PUBLIC    Sound
  50. Sound        PROC    NEAR
  51.         MOV    DX,OFFSET msg1    ;intro greeting
  52.         MOV    AH,9
  53.         INT    21h
  54. s1:
  55.         MOV    BX,0700h    ;set 1/pitch - highest possible tone
  56.         MOV    AL,0B6h     ;"switch" to
  57.         OUT    43h,AL        ;initalize the speaker timer
  58. s2:
  59.         MOV    AX,BX        ;OUT instruction can only handle the
  60.         OUT    42h,AL        ;least significant byte (LSB) from
  61.         MOV    AL,AH        ;the AX register  (AL)
  62.         OUT    42h,AL
  63.         IN    AL,61h        ;grab speaker port
  64.         OR    AL,3        ;turn on speaker
  65.         OUT    61h,AL
  66.         DEC    BX        ;increase the pitch
  67.         CMP    BX,0350h
  68.         JZ    s1
  69. sinput:
  70.         PUSH    AX
  71.         PUSH    BX
  72.         MOV    AH,0Bh        ;check standard input device
  73.         INT    21h
  74.         OR    AL,AL        ;any character waiting ?
  75.         POP    BX
  76.         POP    AX
  77.         JZ    s2        ;go do new tone
  78. soff:
  79.         IN    AL,61h        ;grab speaker port
  80.         XOR    AL,3        ;turn off speaker
  81.         OUT    61h,AL
  82.         RET
  83. Sound        ENDP
  84.  
  85. Beep        ENDP
  86. code        ENDS
  87.         END    Beep
  88.