Finding an adapter's slot number

Sometimes you may need to determine which microchannel slot (or whether it is even present) a specific adapter is in. These routines scan the MCA bus from the highest numbered MCA slot possible, 8, down to slot 1, for an adapter ID and stop at the first occurance of that adapter (so it would not detect a duplicate adapter ID in a lower numbered slot). If the card is not present the routine returns a "0", otherwise the highest slot number an adapter of that ID is in. Routines that determine the slot numbers for multiple adapters of the same adapter ID would need a modified routine.

Assembly Language Routine
BASIC Language Routine

Assembly Language Routine:

;----------------------------------------------
; 	    WhatSlot Assembly routine
; This routine locates which microchannel slot
; (or even if it is present on the system) an
; adapter is in, given the Adapter ID number.
; The routine CheckMCA should be run first to 
; make sure the system has a microchannel bus.
; 
;    Entry:
;	BX = AdapterID being searched for
;	     Same byte order as the ADF
;
;    Exit:
;	Carry flag clear if adapter found
;	     CL = Slot number of adapter, 1 - 8
;	Carry flag set if adapter not found
;	     CL = 0
;----------------------------------------------

WhatSlot	proc	near
		cli
		clc
		mov	CX,0008
NextSlot:	mov	AL,CL
		add 	AL,07
		out 	96h,AL
		mov 	DX,101h
		in 	AL,DX
		mov 	AH,AL
		dec 	DX
		in 	AL,DX
		cmp 	AX,BX
		jz 	Finished
		loop	NextSlot
		stc
Finished:	out	96h,00
		sti
WhatSlot	endp

BASIC Language Routine:

'---------------------------------------------- 
' 	    WhatSlot BASIC routine
' This routine locates which microchannel slot
' (or even if it is present on the system) an
' adapter is in, given the Adapter ID number.
'    Entry:
'	AdapterID has the adapter ID
'	Same byte order as the ADF
'	i.e.: AdapterID = &HDFE5
'
'    Exit:
' 	WhatSlot holds the highest 
' 	number slot with the adapter 
'	installed, 0 if not present 
'----------------------------------------------

FUNCTION WhatSlot (AdapterID)
	WhatSlot = 0
        FOR SlotNumber = 8 TO (WhatSlot + 1) STEP -1
                OUT &H96, SlotNumber + 7
                IF RIGHT$(HEX$(AdapterID), 4) = (HEX$(INP(&H101)) + HEX$(INP(&H100))) THEN
			WhatSlot = SlotNumber
                        EXIT FOR
                END IF
        NEXT SlotNumber
        OUT &H96, 0
END FUNCTION
Last updated 3 March 2022
Back to the Routines index