* BANKIT2

* This is the main BANKIT routine, and is to be placed in RAM by the powerup
* routine. We may move this routine to RAM on every DSR call, we'll see how
* it goes. See BANKIT;S for more details on the banking routines.
*
* By Brad Snyder for the WHT SCSI Adaptor. 12-23-94.
* Updated 12-28-94 bls
* debug 1-2-95 bls - not finding correct jump address at beginning of banks
* debug 1-3-95 bls - using R0 to index into jump table. TI not happy.
* modify 1-6-95 bls - added stack for bankit to use. Of course, all addresses
*                     changed.
* modify 1-17-95 bls - moved stack handler to rom
*
* BNKST  is currently at >5DD6
* BANKWS is currently at >5DB6

* Note: the CRU base of the SCSI card has been loaded into BANKWS R12 by the
*       powerup routine.

BNKST  AI   R12,8*2           point to mapper
       LDCR R1,4              map in requested bank of eprom
       AI   R12,-8*2
       ANDI R1,>00FF          make it just the offset
       SLA  R1,1              *2
       MOV  @>4000(R1),R1     get address
       B    *R1               branch to called routine

* Branch or BL to here to return to caller. Must have RAM bank 0 active first!

       AI   R12,8*2           return to caller
       LDCR R10,4             map caller's bank back in
       AI   R12,-8*2          restore R12
       RTWP                   BACK to caller

BNKEND EQU  $
BRAD   EQU  >5DD6             address to load banking code into

* Code to return from the DSR from any rom bank. Also copied to ram at
* powerup. Maps in ROM 0 and returns to TI OS.
*
* By David Nieters 02-10-95

DSRRT1 ANDI R12,>FF00
       AI   R12,8*2           point to ROM mapper
       CLR  R1
       LDCR R1,4              map in ROM bank 0
       ANDI R12,>FF00         restore R12
       MOV  @SAVR1,R1
       MOV  @SAVR11,R11
       INCT R11
       RT                     28 bytes
DSRRT2 EQU  $

