Finding an Adapter's Slot Number

Introduction
Assembly Routine
BASIC Routine

Content by David L. Beem (original HERE). Edited by Tomáš Slavotínek.
Last update: 03 Oct 2021


Introduction

Sometimes you may need to determine which Micro Channel 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 occurrence 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 Routine

;----------------------------------------------
; WhatSlot Assembly routine
;
; This routine locates which Micro Channel 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 Micro Channel 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 Routine

'----------------------------------------------
' WhatSlot BASIC routine
'
' This routine locates which Micro Channel 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

Content created and/or collected by:
Louis F. Ohland, Peter H. Wendt, David L. Beem, William R. Walsh, Tatsuo Sunagawa, Tomáš Slavotínek, Jim Shorney, Tim N. Clarke, Kevin Bowling, and many others.

Ardent Tool of Capitalism is maintained by Tomáš Slavotínek.
Last update: 02 Nov 2024 - Changelog | About | Legal & Contact