home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / alde_c / misc / util / super_c / nlib.asm < prev    next >
Encoding:
Assembly Source File  |  1980-01-01  |  1.8 KB  |  52 lines

  1. ;               Noise Library
  2.  
  3. _TEXT   segment byte public 'CODE'      ; Place the code in the code segment
  4.         assume  CS:_TEXT                ; Assume the CS register points to it
  5.  
  6. ; _sound(count) 
  7. ;
  8. ; Function: Turn on the speaker and have it play the note specified by
  9. ; count.
  10. ;
  11. ; Algorithm: Write the count to the portion of the timer that drives the
  12. ; speaker, and then enable the speaker output.
  13.  
  14.         public _sound           ; Routine is available to other modules
  15.  
  16.         count = 4               ; Offset from BP to the parameter count
  17.  
  18. _sound  proc near               ; NEAR type subroutine
  19.         push    bp              ; Save the BP register
  20.         mov     bp,sp           ; Set BP to SP; easier to access parameters
  21.         mov     al,0B6H         ; Tell timer to prepare for a new count
  22.         out     43H,al
  23.         mov     ax,[bp+count]   ; Write new count to the timer, low byte 1st
  24.         out     42H,al
  25.         mov     al,ah           ; Then high byte
  26.         out     42H,al
  27.         in      al,61H          ; Enable speaker output from timer
  28.         or      al,3
  29.         out     61H,al
  30.         pop     bp              ; Restore the BP register
  31.         ret                     ; Return to caller
  32. _sound  endp                    ; End of subroutine
  33.  
  34. ; _sndoff()
  35. ;
  36. ; Function: Turn off speaker.
  37. ;
  38. ; Algorithm: Disable speaker output from timer.
  39.  
  40.         public _sndOff          ; Routine is available to other modules
  41.  
  42. _sndOff proc near               ; NEAR type subroutine
  43.         in      al,61H          ; Disable speaker output from timer
  44.         and     al,0FCH
  45.         out     61H,al
  46.         ret                     ; Return to caller
  47. _sndOff endp                    ; End of subroutine
  48.  
  49. _TEXT   ends                    ; End of code segment
  50.         end                     ; End of assembly code
  51.  
  52.