{File name BusExtCH.mc Description: DandeLion Interlisp Emulator Bus Extension Author: Purcell Created: 31-May-84 16:45:34 Purcell 8-Mar-85 18:32:51 add bytes reversed code Purcell 6-Mar-85 14:57:37 fix bug in pcbus charnley early feb {%L} change for intermezzo Purcell 4-Aug-84 3:07:29 remove delay; mask adc to 12 bits Purcell 4-Aug-84 1:02:24 add delay to pcblt Purcell 1-Aug-84 20:48:27 forgot to "_ib" after "_ibNA"; 5 needed in pipe primed Purcell 30-Jul-84 20:59:53 start more pipe on inputs (4) (5 needs work] Purcell 28-Jul-84 15:56:16 check out Purcell 28-Jul-84 11:53:43 more desk checking of block, test bit 9 Purcell 27-Jul-84 0:42:14 restart pc bus block opcode Purcell 11-Jul-84 22:39:45 pc bus block write Purcell 11-Jul-84 16:41:15 add pipe delay in input and move TOSH_ earlier Purcell 10-Jul-84 9:29:57 fix Y0 bug in output Purcell 26-Jun-84 14:19:53 } {INPUT: TOSH _ smallpl, DISP4[MiscIn], c1, at[0D,10, MiscDisp];} { (SETQ MBUS.OUTL (PLUS 0 (LLSH REG 4))) (SETQ MBUS.OUTM (PLUS 11 (LLSH REG 4))) (SETQ MBUS.INL (PLUS 9 (LLSH REG 4))) (SETQ MBUS.INM (PLUS 10 (LLSH REG 4))) (\DEVICE.OUTPUT DATA MBUS.OUTL) (\DEVICE.OUTPUT DATA MBUS.OUTM) (SETQ DATA (\DEVICE.INPUT MBUS.INL)) (SETQ DATA (\DEVICE.INPUT MBUS.INM)) (\PCBLT (alpha op) VIRTUALADDR PCADDRH PCADDRL COUNT) L3Disp values initialized to alpha byte 1,2 bit data size: 0=word, 1=byte, 2=reversed bytes, 3=nibble 4 bit 0=output, 1=input 8 bit extra states 0 read/output word 1,9 read/output bytes 2,A read/output bytes reversed 3,7,B,F read/output nibbles 4 input/write word 5,D input/write bytes 6,E input/write bytes reversed } {PV} RegDef[rAddr, R, 3]; {pc bus address low 16 bits} {TOSH} RegDef[rDataIn, R, 1]; {TT} RegDef[rDataOut, R, 2]; {rDataOut not needed during cross so alias with and use TT} {Rx real TOS word count remaining (end input/write at 0; end read/output at -1)(fetch from virt+TOS-1) Q used by mapping routine } { RegDef[uVirtL, U, 27];{TT}{uTT} {ok} RegDef[uVirtH, U, 0C];{TOS}{ibNA} {BitBlt}{OK} RegDef[uBusCtl, U, 2];{fZ=2} {BitBlt}{OK} RegDef[uAddr, U, 33];{rAddr}{fZ=3} {OK} - moved to 43 RegDef[uDataOut, U, 12];{fZ=2} {OK} - moved to 42 } {L0 unused L1 Fix {L1.NoFixes} L2 0=normal, 1=test loop L3 phase and op} PCBKW: FloatNop, L1 _ L1.NoFixes, c1, opcode[60'b]; uPV _ PV, L2 _ 0, c2; Rx _ 0FF + 1, c3; Q _ uPPsave, c1; PPort _ Q and ~Rx, c2; , c3; pcA1: MAR _ [rhS, S+0], c1; S _ S - 2, c2; rAddr{L} _ MD, FloatNop, c3; pcA2: MAR _ [rhS, S+0], c1; S _ S - 2, c2; FLTimes.WA.WB{% fZ=3}, Float.M, Xbus{mBusAddrM} _ MD, c3; pcA3: MAR _ [rhS, S+0], c1; S _ S - 1, c2; uTOS _ TOS, TT _ MD{virtL}, c3; {TT=rDataOut=virtL} pcA4: Rx{2*TOS} _ TOS LShift1, Xbus _ ibNA, XDisp, c1; rDataIn{4*TOS} _ Rx LShift1, DISP4[pcAdd, 0C], c2; rAddr _ rAddr + TOS, GOTO[pcArg], c3, at[0C, 10, pcAdd];{word addressing} rAddr _ rAddr + Rx{2*TOS}, GOTO[pcArg], c3, at[0D, 10, pcAdd];{byte addressing} rAddr _ rAddr + Rx{2*TOS}, GOTO[pcArg], c3, at[0E, 10, pcAdd];{byte reversed} rAddr _ rAddr + rDataIn{4*TOS}, GOTO[pcArg], c3, at[0F, 10, pcAdd];{nibble addressing} pcArg: MAR _ [rhS, S+0], c1; S _ S + 5, c2; uVirtL _ TT, TT _ MD{virtH}, c3; rAddr _ rAddr -1, c1; uAddr _ rAddr, Rx _ 0{force remap}, c2; uVirtH _ TT, Xbus _ ibNA, XDisp, c3; pcBCtl: TOSH _ 0{uBusCtl}, Float.L, Xbus{mBusAddrL} _ uAddr, BRANCH[pcBOut, pcBIn, 0B], c1; pcBIn: TOSH _ TOSH or 1, GOTO[pcCtlj], c2; {set mBusCtl for reads} pcBOut: TOSH _ TOSH or 2, GOTO[pcCtlj], c2; {set mBusCtl for writes} pcCtlj: uBusCtl _ TOSH, c3; Xbus _ ib, XDisp, c1; Float.M, Xbus{mBusCtl} _ uBusCtl, L3 _ 0, DISP4[pcBlk], c2; {pcRead subroutine; return to pcReadRet+L3, use uAddr, update uAddr, read virt+TOS-1} pcRead: MAR _ Rx _ [rhRx, Rx-1], BRANCH[$, pcDn2], c1; rAddr _ rAddr -1, Float.L, Xbus{mBusAddrL} _ uAddr, L3Disp, BRANCH[$, pcRcr, 1], c2; pcRead3: uAddr _ rAddr, rDataOut _ MD, RET[pcReadRet], c3; {pcBus subroutine: return to pcBusRet+L3, used both for input and output; rDataIn ignored on output} pcBus2: Noop, c2; pcBus3: uAddr _ rAddr, c3; uDataOut _ rDataOut, c1;{% good for 5; ok others ?} Xbus _ FloatResult{mBusIData}, FLFloatA{fZ=2}, Float.L, c2; pcBus: Noop, c3; pcBus1: Noop, CANCELBR[$, 3], c1; Noop, c2; Ybus _ rDataIn, Xbus _ PPort, XwdDisp{9(,10)}, c3; Q _ rDataIn or FloatResult, L3Disp, BRANCH[$, pcWait, 1], c1; rDataIn _ Q, Float.L, Xbus{mBusOData} _ uDataOut, RET[pcBusRet], c2; pcWait: Xbus _ FloatResult{mBusIData}, FLFloatA{fZ=2}, Float.L, CANCELBR[pcBus, 0F], c2; pcBus3CH: uAddr _ rAddr, c3; uDataOut _ rDataOut, c1;{% good for 5; ok others ?} Xbus _ FloatResult{mBusIData}, FLFloatA{fZ=2}, Float.L, c2; pcBusCH: Noop, c3; pcBus1CH: Ybus _ TOS - 1, ZeroBr, CANCELBR[$, 3], c1; BRANCH[$, pcskipit], c2; Ybus _ rDataIn, Xbus _ PPort, XwdDisp{9(,10)}, c3; Q _ rDataIn or FloatResult, L3Disp, BRANCH[$, pcWaitCH, 1], c1; rDataIn _ Q, Float.L, Xbus{mBusOData} _ uDataOut, RET[pcBusRet], c2; pcWaitCH: Xbus _ FloatResult{mBusIData}, FLFloatA{fZ=2}, Float.L, CANCELBR[pcBus, 0F], c2; pcskipit: Ybus _ rDataIn, Xbus _ PPort, XwdDisp{9(,10)}, c3; Q _ rDataIn or FloatResult, L3Disp, BRANCH[$, pcWaitCHs, 1], c1; rDataIn _ Q, RET[pcBusRet], c2; pcWaitCHs: Xbus _ FloatResult{mBusIData}, FLFloatA{fZ=2}, Float.L, CANCELBR[pcBus, 0F], c2; {0: Block Read/Output Words}{uAddr=rAddr=last, TOS=cnt} CALL[pcRead], c3, at[0, 10, pcBlk]; {pcRead: MAR _ Rx _ [rhRx, Rx-1], c1; pcRead2: rAddr _ rAddr -1, Float.L, Xbus{mBusAddrL} _ uAddr, L3Disp, BRANCH[$, pcRcr, 1], c2; uAddr _ rAddr, rDataOut _ MD, RET[pcReadRet], c3; } pcOW: TOS _ TOS -1, CarryBr, c1, at[0, 10, pcReadRet]; uDataOut _ rDataOut, BRANCH[pcDn, pcBus, 0E], c2; {pcBus: Xbus _ PPort, XwdDisp{9,10}, c3; pcBus1: Q _ rDataIn or FloatResult, L3Disp, BRANCH[$, pcWait, 1], c1; rDataIn _ Q, Float.L, Xbus{mBusOData} _ uDataOut, RET[pcBusRet], c2; } Noop, CALL[pcRead], c3, at[0, 10, pcBusRet], c3; {1: Block Read/Output Bytes} CALL[pcRead], c3, at[1, 10, pcBlk]; {pcRead: MAR _ Rx _ [rhRx, Rx-1], c1; pcRead2: rAddr _ rAddr -1, Float.L, Xbus{mBusAddrL} _ uAddr, L3Disp, BRANCH[$, pcRcr, 1], c2; uAddr _ rAddr, rDataOut _ MD, RET[pcReadRet], c3; } pcOB: TOS _ TOS -1, CarryBr, L3 _ 9, c1, at[1, 10, pcReadRet]; uDataOut _ rDataOut, BRANCH[pcDn, pcBus, 0E], c2; rDataOut _ rDataOut LRot8, L3 _ 1, c3, at[9, 10, pcBusRet]; pcOBB: rAddr _ rAddr -1, Float.L, Xbus{mBusAddrL} _ uAddr, GOTO[pcBus2], c1; CALL[pcRead], c3, at[1, 10, pcBusRet], c3; {2: Block Read/Output Bytes Reversed} Ybus _ TOS, ZeroBr, CALL[pcRead], c3, at[2, 10, pcBlk]; {pcRead: MAR _ Rx _ [rhRx, Rx-1], c1; pcRead2: rAddr _ rAddr -1, Float.L, Xbus{mBusAddrL} _ uAddr, L3Disp, BRANCH[$, pcRcr, 1], c2; uAddr _ rAddr, rDataOut _ MD, RET[pcReadRet], c3; } {pcOBr: TOS _ TOS -1, CarryBr, L3 _ 0A, c1, at[2, 10, pcReadRet]; rDataOut _ rDataOut LRot8, BRANCH[pcDnR, pcBusR, 0E], c2; pcBusR: uDataOut _ rDataOut, Xbus _ PPort, XwdDisp{9(,10)}, GOTO[pcBus1], c3; pcDnR: S _ S - 6, L2Disp, GOTO[pcDn1], c3; } pcOBr: rDataOut _ rDataOut LRot8, c1, at[2, 10, pcReadRet]; uDataOut _ rDataOut, L3 _ 0A, c2; TOS _ TOS-1, Xbus _ PPort, XwdDisp{9(,10)}, GOTO[pcBus1], c3; {TOS was tested for zero at Read} rDataOut _ rDataOut LRot8, L3 _ 2, c3, at[0A, 10, pcBusRet]; pcOBBr: rAddr _ rAddr -1, Float.L, Xbus{mBusAddrL} _ uAddr, GOTO[pcBus2], c1; Ybus _ TOS, ZeroBr, , CALL[pcRead], c3, at[2, 10, pcBusRet], c3; {3: Block Read/Output Nibbles} CALL[pcRead], c3, at[3, 10, pcBlk]; {pcRead: MAR _ Rx _ [rhRx, Rx-1], c1; pcRead2: rAddr _ rAddr -1, Float.L, Xbus{mBusAddrL} _ uAddr, L3Disp, BRANCH[$, pcRcr, 1], c2; uAddr _ rAddr, rDataOut _ MD, RET[pcReadRet], c3;} pcON: TOS _ TOS -1, CarryBr, L3 _ 7, c1, at[3, 10, pcReadRet]; uDataOut _ rDataOut, BRANCH[pcDn, pcBus, 0E], c2; rDataOut _ rDataOut LRot12, L3 _ 0B, c3, at[7, 10, pcBusRet]; pcONN: rAddr _ rAddr -1, Float.L, Xbus{mBusAddrL} _ uAddr, GOTO[pcBus2], c1; rDataOut _ rDataOut LRot12, L3 _ 0F, c3, at[0B, 10, pcBusRet]; pcONNN: rAddr _ rAddr -1, Float.L, Xbus{mBusAddrL} _ uAddr, GOTO[pcBus2], c1; rDataOut _ rDataOut LRot12, L3 _ 3, c3, at[0F, 10, pcBusRet]; pcONNNN: rAddr _ rAddr -1, Float.L, Xbus{mBusAddrL} _ uAddr, GOTO[pcBus2], c1; Noop, CALL[pcRead], c3, at[3, 10, pcBusRet], c3; pcInPipeStart: uAddr _ rAddr, c1; Float.L, Xbus{mBusOData} _ uDataOut, c2; Float.L, Xbus{mBusAddrL} _ uAddr, c3; rAddr _ rAddr -1, Xbus _ FloatResult{mBusIData}, FLFloatA{fZ=2}, Float.L, c1; uAddr _ rAddr, rDataIn _ 0, GOTO[pcBus], c2; {4: Block Input/Write Words} rAddr _ rAddr -1, c3, at[4, 10, pcBlk]; pcInPipeStartCH: uAddr _ rAddr, c1; Float.L, Xbus{mBusOData} _ uDataOut, c2; Float.L, Xbus{mBusAddrL} _ uAddr, c3; rAddr _ rAddr -1, Xbus _ FloatResult{mBusIData}, FLFloatA{fZ=2}, Float.L, c1; uAddr _ rAddr, rDataIn _ 0, GOTO[pcBusCH], c2; rDataIn _ rDataIn, CALL[pcWrite], c3, at[4, 10, pcBusRet]; pcIW: TOS _ TOS -1, NZeroBr, c1, at[4, 10, pcWriteRet]; uAddr _ rAddr, rDataIn _ 0, BRANCH[pcDnCH, pcBusCH, 0E], c2; pcWrite: MAR _ Rx _ [rhRx, Rx-1], c1; pcWrite2: MDR _ rDataIn, Float.L, Xbus{mBusAddrL} _ uAddr, L3Disp, BRANCH[$, pcWcr, 1], c2; rAddr _ rAddr -1, Xbus _ FloatResult{mBusIData}, FLFloatA{fZ=2}, Float.L, RET[pcWriteRet], c3; {5: Block Input/Write Bytes} rAddr _ rAddr -1, GOTO[pcInPipeStart], c3, at[5, 10, pcBlk]; rDataIn _ rDataIn {and 0F}, L3 _ 0D, c3, at[5, 10, pcBusRet]; pcIBB: rAddr _ rAddr -1, Float.L, Xbus{mBusAddrL} _ uAddr, c1; rDataIn _ rDataIn LRot8, GOTO[pcBus3CH], c2; rDataIn _ rDataIn LRot8, CALL[pcWrite], c3, at[0D, 10, pcBusRet]; pcIB: TOS _ TOS -1, NZeroBr, L3 _ 5, c1, at[0D, 10, pcWriteRet]; uAddr _ rAddr, rDataIn _ 0, BRANCH[pcDn, pcBus, 0E], c2; {6: Block Input/Write Bytes Reversed} rAddr _ rAddr -1, GOTO[pcInPipeStart], c3, at[6, 10, pcBlk]; rDataIn _ rDataIn {and 0F}, L3 _ 0E, c3, at[6, 10, pcBusRet]; pcIBBr: rAddr _ rAddr -1, Float.L, Xbus{mBusAddrL} _ uAddr, c1; rDataIn _ rDataIn LRot8, GOTO[pcBus3CH], c2; rDataIn _ rDataIn LRot0, CALL[pcWrite], c3, at[0E, 10, pcBusRet]; pcIBr: TOS _ TOS -1, NZeroBr, L3 _ 6, c1, at[0E, 10, pcWriteRet]; uAddr _ rAddr, rDataIn _ 0, BRANCH[pcDn, pcBus, 0E], c2; {Exceptions} {Remap to Virt+TOS-1}{don't fault if TOS=0} pcWcr: Noop, CANCELBR[pcCr, 0F], c3; pcRcr: rAddr _ rAddr +1, CANCELBR[pcCr, 0F], c3; pcCr: TOS _ TOS -1, CarryBr, c1; TT _ uVirtL, BRANCH[pcCz, pcCnz], c2; pcCz: rhTT _ uVirtH, GOTO[pcMp], c3; pcCnz: TT _ TT + TOS, CarryBr, rhTT _ uVirtH, GOTO[pcMp], c3; pcInc: Q _ rhTT+1, LOOPHOLE[byteTiming], c2; rhTT _ Q LRot0, c3; pcMp: Map _ Q _ [rhTT, TT], BRANCH[pcMp2, pcInc], c1; pcMp2: TOS _ TOS + 1, c2; Rx _ rhRx _ MD, XwdDisp, c3; Map _ Q _ [rhTT, TT], BRANCH[$, pcFault, 1], c1; MDR _ Rx or 30, c2; L3Disp, c3; pcMpD: MAR _ Rx _ [rhRx, TT+0], BRANCH[pcRead2, pcWrite2, 0B], c1; pcRead2: rAddr _ rAddr -1, Float.L, Xbus{mBusAddrL} _ uAddr, L3Disp, GOTO[pcRead3], c2; {% fix ups} pcFault: TOSH _ smallpl, c2; Q _ uPPsave, c3; PPort _ Q, c1; PV _ uPV, GOTO[RWTrap], c2; pcDnCH: GOTO[pcDn1], c3; pcDn2: , CANCELBR[$, 2], c2; pcDn: , {L2Disp,} c3; pcDn1: TOSH _ smallpl, L2Disp, CANCELBR[$, 3], {BRANCH[$, pcRep],} c1; PV _ uPV, BRANCH[$, pcRep], c2; pcAlmost: Rx _ uPPsave, c3; pcEnd: PPort _ Rx, L2 _ L2.0, c1; S _ S - 6, IBDisp, c2; PC _ PC + 1, L2 _ L2.0, DISPNI[OpTable], c3; {pcRep: , c2;} pcRep: TOS _ uTOS, GOTO[pcA1], c3; BusX: FloatNop{free BX in 2 BX cycles}, c2, at[09,10,MiscIn];{read L} TOS _ TOS LRot12, {FloatUMS,} c3; Ybus _ TOS, AltUaddr, c1; FloatULP, TOS _ FloatResult, c2; pcInDn: TOS _ FloatResult, c3; GOTO[IB.nop], c1; FloatNop{free BX in 2 BX cycles}, c2, at[0A,10,MiscIn];{read M} TOS _ TOS LRot12, {FloatUMS,} c3; Ybus _ TOS, AltUaddr, c1; FloatUMP, TOS _ FloatResult, GOTO[pcInDn], c2; {TT _ MD,} c3, at[0,10,MiscOut];{Write L} {%L FloatNop{free BX in 2 BX cycles}, c1; TOS _ TOS LRot12, FloatUMS, c2; rhRx _ nRhS, Rx _ S + 2, c3; %L} FloatNop{free BX in 2 BX cycles}, Rx _ S - 0 - 1, c1; TOS _ TOS LRot12, FloatUMS, c2; rhRx _ nRhS, Rx _ Rx + 3, c3; MAR _ Rx _ [rhRx, Rx + 0], c1; Ybus _ TOS, AltUaddr, L2 _ L2.0, IBDisp, c2; FloatULP, Xbus _ MD { _ FloatResult}, L2 _ L2.0, DISPNI[OpTable], c3; {TT _ MD,} c3, at[0B,10,MiscOut];{Write M} {%L FloatNop{free BX in 2 BX cycles}, c1; TOS _ TOS LRot12, FloatUMS, c2; rhRx _ nRhS, Rx _ S + 2, c3; %L} FloatNop{free BX in 2 BX cycles}, Rx _ S - 0 - 1, c1; TOS _ TOS LRot12, FloatUMS, c2; rhRx _ nRhS, Rx _ Rx + 3, c3; MAR _ Rx _ [rhRx, Rx + 0], c1; Ybus _ TOS, AltUaddr, L2 _ L2.0, IBDisp, c2; FloatUMP, Xbus _ MD, L2 _ L2.0, DISPNI[OpTable], c3; { E N D }