National Instruments PC-DIO-96 Switch User Manual


 
Chapter 4 Register-Level Programming
© National Instruments Corporation 4-25 PC-DIO-96 User Manual
mov ax,[bp+8] ; Get ofs into ax
mov word ptr isrb_addr[0],ax ; Save address in variable
mov ax,[bp+10] ; Get seg into ax
mov word ptr isrb_addr[2],ax ; Save address in variable
; set interrupt vector--save the current vector before writing out new one
mov ax,[bp+6] ; Get interrupt level
cmp al,7 ; Check to see if it belongs to master
ja short slave ; or slave interrupt chip
add al,008h ; Offset for master vector list
jmp short setvec ; Go set the vector
slave:
add al,068h ; Offset for slave vector list
mov slave_ack,1 ; Flag for slave channel
setvec:
push ax ; Save vector number for later
mov ah,35h ; Get current vector
int 21h ; Get previous int_addr in es:bx
pop ax ; Restore vector number
mov cx,cs ; Prep to compare current/new vectors
mov dx,es
cmp dx,cx ; See if vector is already there
jne short ii_0
cmp bx,offset _isr_handler
je short ii_exit ; Vector already installed--exit
ii_0:
mov vect_num,al ; Save vector number for remove_isr
mov word ptr int_addr[0],bx ; Save the address
mov word ptr int_addr[2],es
push ds ; Save the data segment
mov ds,cx ; Copy cx (== cs) into ds
mov dx,offset _isr_handler ; ds:dx points to new handler
mov ah,25h
int 21h ; Install the handler in the system
pop ds
; mask interrupt level in the interrupt controller register and store
; the original setting of the mask bit for the selected interrupt level
mov cx,[bp+6] ; Get interrupt level
mov bx,1 ; Generate some masks
shl bx,cl
mov cx,bx ; cx has 1 in bit pos of int-level
not bx ; bx has 0 in bit pos of int-level
in al,maskm ; Get mask data from master chip
jmp $+2 ; Delay--wait for data transfer
and cl,al ; Determine setting of mask bit
and al,bl ; Enable interrupts for selected level
out maskm,al
jmp $+2 ; Delay--wait for data transfer
in al,masks ; Get mask data from slave chip
jmp $+2 ; Delay--wait for data transfer
and ch,al ; Determine setting of mask bit
and al,bh ; Enable interrupts for selected level
out masks,al
mov int_mask,cx ; Save the previous value of the mask