home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / asm_programming / ASCIIORG.ASM < prev    next >
Assembly Source File  |  1990-10-02  |  2KB  |  41 lines

  1. ;ASCII Organ
  2.  
  3.         code    segment
  4.         org     100h
  5.         assume  cs:code
  6.  
  7. timer   equ     42h
  8. speaker equ     61h
  9.  
  10. start:  call    getkey          ; store key pressed in AL
  11.         cmp     al,1bh          ; escape?
  12.         jne     skip
  13.         int     20h
  14. skip:   call    beep            ; if not escape, beep according to
  15.         jmp     start           ; value in AL, and return
  16.  
  17. getkey: mov     ah,7            ; prepare for interrupt
  18.         int     21h             ; execute DOS function 7
  19.         ret            ; return with key in AL
  20.  
  21. beep:   mov     bl,al           ; store key in BL
  22.         mov     al,0b6h         ; prepare timer for
  23.         out     timer+1,al      ; accepting new division
  24.         mov     al,0            ; send 0 as LSB
  25.         out     timer,al        ; of the new divisor
  26.         mov     al,bl           ; and key value
  27.         out     timer,al        ; like MSB
  28.         mov     al,4fh          ; start sound by linking the
  29.         out     speaker,al      ; speaker and timer
  30.         mov     cx,0ffffh       ; pause
  31.         rep     lodsw           ; while the note is played
  32.         mov     al,4dh          ; stop by cutting the connection
  33.         out     speaker,al      ; between speaker and timer
  34.         mov     ah,2            ; prepare for DOS output function
  35.         mov     dl,0eh          ; (out) character to send
  36.         int     21h             ; symbol of the note to the screen
  37.         ret
  38.  
  39. code    ends
  40.         end     start
  41.