home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / asm / MISC_ASM.ZIP / BEEP04.ASM < prev    next >
Encoding:
Assembly Source File  |  1987-02-28  |  3.4 KB  |  135 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. ; *     1.04 -  another siren (mod of v1.03)            -    02/28/87
  13. ;
  14. ;  For Public Domain Use.  Not for Sale or Hire.
  15. ;------------------------------------------------------------------------
  16. COMMENT *
  17.        As requested by Viggo Jensen.
  18.  
  19.    Beep utility - sounds alarm until any key is pressed.
  20.  
  21.           Obviously, best use of this small utility is at
  22.           the end of a batch file.  Could be used to replace
  23.           the DOS "pause" command.
  24. *
  25. ;------------------------------------------------------------------------
  26. code        SEGMENT BYTE PUBLIC 'code'
  27. ASSUME        CS:code,DS:code,SS:code
  28.  
  29.         ORG    100h
  30.  
  31. Beep        PROC    FAR
  32.  
  33. start:
  34.         MOV    DX,OFFSET msg1    ;intro greeting
  35.         MOV    AH,9
  36.         INT    21h
  37. noise:
  38.         CALL    Sound_Up    ;sound the horn - up scale
  39.         CALL    Sound_Down    ;        - down scale
  40. exit:
  41.         MOV    AH,4Ch
  42.         INT    21h
  43.  
  44. ;------------------------------------------------------------------------
  45. ; Work Area - constants,equates,messages
  46. ;------------------------------------------------------------------------
  47. cr        EQU    0Dh        ;carriage return
  48. lf        EQU    0Ah        ;line feed
  49. esc        EQU    01Bh        ;escape char
  50.  
  51. msg1        DB    cr,lf,'Beeping - press any key to quit...','$'
  52.  
  53. ;--------------------------------------------------------------------------
  54. ; Sub-Routines: Declare each Proc PUBLIC for use with MapSym & SymDeb v4.0
  55. ;--------------------------------------------------------------------------
  56.         PUBLIC    Sound_Up
  57. Sound_Up    PROC    NEAR
  58. s1:
  59.         MOV    BX,0800h    ;set 1/pitch - lowest possible tone
  60.         MOV    AL,0B6h     ;"switch" to
  61.         OUT    43h,AL        ;initalize the speaker timer
  62. s2:
  63.         MOV    AX,BX        ;OUT instruction can only handle the
  64.         OUT    42h,AL        ;least significant byte (LSB) from
  65.         MOV    AL,AH        ;the AX register  (AL)
  66.         OUT    42h,AL
  67.         IN    AL,61h        ;grab speaker port
  68.         OR    AL,3        ;turn on speaker
  69.         OUT    61h,AL
  70.         DEC    BX        ;increase the pitch
  71.         CMP    BX,0350h    ;predefined upper tone limit
  72.         JZ    sdown        ;change to whatever suits you
  73. sinput:
  74.         PUSH    AX
  75.         PUSH    BX
  76.         MOV    AH,0Bh        ;check standard input device
  77.         INT    21h
  78.         OR    AL,AL        ;any character waiting ?
  79.         POP    BX
  80.         POP    AX
  81.         JZ    s2        ;go do new tone
  82. soff:
  83.         CALL    Sound_Off
  84. sdown:
  85.         RET
  86. Sound_Up    ENDP
  87.  
  88. ;--------------
  89.         PUBLIC    Sound_Down
  90. Sound_Down    PROC    NEAR
  91. d1:
  92.         MOV    BX,0300h    ;set 1/pitch - highest possible tone
  93.         MOV    AL,0B6h     ;"switch" to
  94.         OUT    43h,AL        ;initalize the speaker timer
  95. d2:
  96.         MOV    AX,BX        ;OUT instruction can only handle the
  97.         OUT    42h,AL        ;least significant byte (LSB) from
  98.         MOV    AL,AH        ;the AX register  (AL)
  99.         OUT    42h,AL
  100.         IN    AL,61h        ;grab speaker port
  101.         OR    AL,3        ;turn on speaker
  102.         OUT    61h,AL
  103.         INC    BX        ;decrease the pitch
  104.         CMP    BX,0700h    ;predefined lower tone limit
  105.         JZ    ddown
  106. dinput:
  107.         PUSH    AX
  108.         PUSH    BX
  109.         MOV    AH,0Bh        ;check standard input device
  110.         INT    21h
  111.         OR    AL,AL        ;any character waiting ?
  112.         POP    BX
  113.         POP    AX
  114.         JZ    d2        ;go do new tone
  115. doff:
  116.         CALL    Sound_Off
  117. ddown:
  118.         JMP    noise        ;start this cycle all over
  119. Sound_Down    ENDP
  120.  
  121. ;--------------
  122.         PUBLIC    Sound_Off
  123. Sound_Off    PROC    NEAR
  124.         IN    AL,61h        ;grab speaker port
  125.         XOR    AL,3        ;turn off speaker
  126.         OUT    61h,AL
  127.         JMP    Exit
  128. Sound_Off    ENDP
  129.  
  130. ;--------------
  131.  
  132. Beep        ENDP
  133. code        ENDS
  134.         END    Beep
  135.