;
interrupt       segment at 0h           ;Interrupt segment.
        org 0Ah*4                       ;IRQ 2
flag_int        dw 2 dup (?)
interrupt       ends
;
;
code    segment para public 'code'
        assume cs:code
        org 100h
begin:  jmp setup_int                   ;Jump to setup routine.
        db 'Property of Fischer Computer Systems.  Angwin CA  USA'
title:  db 'SEC-PC interrupt loaded.',0dh,0ah
        db 'Courtesy of Fischer Computer Systems.  Angwin CA  USA.',0dh,0ah
        db '$'

main    proc far                        ;This is the interupt routine.
        sti                             ;Enable int.
        push ax                         ;Save affected registers.
        push cx
        push dx
;

        mov dx,330h                     ;Copy counters on SEC-PC
        mov al,1
        out dx,al
        mov dx,333h                     ;Turn off interrupts on SEC-PC
        mov al,0
        out dx,al

        call squeak

        mov dx,20h                      ;Send EOI to 8259
        mov al,20h
        out dx,al

        pop dx                          ;Return from interrupt.
        pop cx
        pop ax
        iret
main    endp

;---------------------------------------------------------------------------
;SQUEAK uses the 8253 timer chip to emit a short tone to the speaker.
;
squeak        proc near
              mov al,182                ;notify 8253 that freq. data is coming
              out 67,al
              mov al,00h                ;send frequency (0 = 776.8 Hz)
              out 66,al
              mov al,8
              out 66,al
              in al,97                  ;activate speaker
              or al,3
              out 97,al
              mov cx,800h              ;time delay for sound duration
squeak1:      loop squeak1
              in al,97                  ;deactivate speaker
              and al,252
              out 97,al

              mov al,182                ;Do it again
              out 67,al
              mov al,00h              
              out 66,al
              mov al,3
              out 66,al
              in al,97                
              or al,2
              out 97,al
              mov cx,800h            
squeak2:      loop squeak2
              in al,97                
              and al,252
              out 97,al

              ret
squeak        endp
;

;----------------------------------------------------------------------
;This is the routine that poke in the interrupt jump address.
;
setup_int       proc near
        assume ds:code, es:code

        mov ah,9
        mov dx,offset title                     ;print title.
        int 21h

        mov dx,333h                             ;reset flag on SEC.
        in al,dx
        mov al,80h                              ;Enable interrupts.
        out dx,al
        mov dx,21h                              ;Enable IRQ 2 on 8259.
        in al,dx
        and al,0fbh
        out dx,al   

        mov ax,interrupt
        mov ds,ax
        assume ds:interrupt                     ;Set DS to Interrupt seg.
        cli                                     ;Disable interrupts.
        mov flag_int,offset main                ;Set new IRQ 2 vector.
        mov flag_int[2],cs
        sti                                     ;Enable interrupts again.
        mov dx,offset setup_int
        int 27h                                 ;Terminate and resident.

setup_int       endp                                          
code    ends
        end begin






