147c ; *************************************************************** ; * Functions for reading from the HAMCOMM comparator interface * ; *************************************************************** DOSSEG .MODEL SMALL .386 .STACK .DATA Org_INT0BIsr dd ? Org_INT08Isr dd ? PUBLIC _timerticks _timerticks dw 0 hz18 dw 18 tick_cntr dw 0 interv dw ? irqmask_save db ? PUBLIC _tone_freq _tone_freq dw ? freqbuf dw 8 dup(?) bufcntr dw 0 latchval dw 0ffffh .CODE PUBLIC _cmpt_init PUBLIC _cmpt_exit _cmpt_init PROC push bx push cx push dx push es ;---------- Fixa h†rdvaruinterrupt fr†n serieporten ---------------------- mov ax,0350Bh ;Fetch INT 0Bh vector (COM2) int 21h mov word ptr[Org_INT0BIsr],bx ;Org_Routine Offset mov word ptr[Org_INT0BIsr+2],es ;Org_Routine Segment push ds ;Code Segment in DS mov ax,cs mov ds,ax mov dx,OFFSET Hz_Int ;Point to new INT0B-routine mov ax,250Bh int 21h pop ds ;----------- Ny INT08-rutin----------------------------------------- ; mov dx,00000h ; mov ax,004a9h ;Calculate interval to call original ; div hz18 ;INT 08 routine ; mov interv,ax ; mov ax,3508h ;Fetch INT 08h vector ; int 21h ; mov word ptr[Org_INT08Isr],bx ;Org_Routine Offset ; mov word ptr[Org_INT08Isr+2],es ;Org_Routine Segment ; push ds ; mov ax,2508h ;Install new Timer ISR ; push cs ; pop ds ; mov dx,offset TIMER_ISR ; int 21h ; pop ds cli mov al,34h ;use linear counting in Timer 0 instead out 43h,al ;of count by two mov al,00h out 40h,al mov al,00h out 40h,al mov al,0B2h ;Re-program timer chn 2 to use out 43h,al ;countdown with restart mode mov al,00h out 42h,al mov al,00h out 42h,al ;------- Necessary steps to activate IRQ3 ------------- mov dx,02f9h ;Set bit 3 in IER mov al,08h ;(Enable Modem Status interrupt) out dx,al mov dx,02fch ;Activate tri-state gate UART<->PIC in al,dx ;DTR high to supply voltage for comp. mov al,0dh ;RTS low for signal ground return out dx,al mov dx,21h ;Set bit 3 to zero in PIC in al,dx ;to enable IRQ 3 mov irqmask_save,al and al,0F7h out dx,al mov dx,02feh ;Reset Modem status register in al,dx ;with a Dummy read ;---------------------------------------------------------------- sti mov al,20h out 20h,al pop es pop dx pop cx pop bx ret _cmpt_init ENDP _cmpt_exit PROC push bx push cx push dx cli mov al,irqmask_save ;Restore old interrupt mask out 21h,al ;(Turn off IRQ 3) mov al,36h out 43h,al mov al,0h out 40h,al mov al,0h out 40h,al ; push ds ; mov dx,word ptr[Org_INT08Isr] ;Restore INT 08 vector ; mov bx,word ptr[Org_INT08Isr+2] ; mov ds,bx ; mov ax,2508h ; int 21h ; pop ds push ds mov dx,word ptr[Org_INT0BIsr] ;Restore INT 0Bh vector mov bx,word ptr[Org_INT0BIsr+2] mov ds,bx mov ax,250bh int 21h pop ds sti pop dx pop cx pop bx ret _cmpt_exit ENDP Hz_Int PROC FAR ASSUME CS:_TEXT,DS:@data push ax push bx push dx push ds push @data pop ds mov dx,2feh ;Dummy read to reset MSR in al,dx mov al,080h ;Latch current timer countdown value out 43h,al ;in Chn 2 in al,42h mov dl,al in al,42h mov dh,al mov ax,latchval mov latchval,dx sub ax,dx mov bx,bufcntr mov freqbuf[bx],ax add bx,2 cmp bx,4 jb no_tabreset mov ax,freqbuf[0] ;Get a whole cycle add ax,freqbuf[2] push bx mov bx,ax ;Calculate frequency in Hz mov dx,00012h ;by dividing 1193180 with mov ax,034dch ;the latched value div bx mov _tone_freq,ax ;store frequency in _tone_freq pop bx xor bx,bx no_tabreset: mov bufcntr,bx sti mov al,20h out 20h,al pop ds pop dx pop bx pop ax iret Hz_Int ENDP TIMER_ISR PROC FAR ASSUME CS:_TEXT,DS:@data push ds push ax push dx push @data pop ds inc word ptr[_timerticks] ;Update tick value inc word ptr[tick_cntr] ;Call original timer ISR mov dx,interv cmp word ptr[tick_cntr],dx ;at proper time interval jnz end_of_ISR mov word ptr[tick_cntr],0 pushf call Org_INT08Isr jmp skip_EOI end_of_ISR: sti mov al,20h out 20h,al skip_EOI: pop dx pop ax pop ds iret TIMER_ISR ENDP END . 0