IMD 1.17: 25/11/2014 12:45:06 82VKXBVERDOS D* BT18:0 68K VERSADOS/RMS68K OBJECT 4.5 (DS,DD 96 tpi 5.1/4" DISK) REVISED: 04/22/86 DISK 18 OF 24  BT18 82VKXBVERDOS 0420±k-|CMR‡|-------->|User…|-------->|‚InputBuffer1‚|/*‰|Parameter|‰|Task'sƒ|‰+------------------+*‰|Block…|‰|I/O†|„.Ž.*‰+-----------+‰|Command‚|„.Ž.*Ÿ|Block„|„.Ž.*Ÿ|Š|*Ÿ|Š|‰+------------------+ *Ÿ|Š|-------->|‚InputBuffern‚|#*Ÿ+----------+‰+------------------+**´Note:‚Inputbuffers.*‰+-----------+‰+----------+‰are‚used‚only‚for:*‚A5--->|CCB‡|-------->|MVME-600|‰theMEASUREcommand./*‰|(Channel‚|‰|Memory-‚|‰Theyarenotpresent,*‰|Controlƒ|‰|Mappedƒ|‰forothercommands.*‰|Block)„|‰|I/OArea|*‰+-----------+‰+----------+***‰+-----------+*‚A6--->|TCB‡| *‰|(Task…| *‰|Controlƒ| *‰|Block)„|*‰+-----------+**E*‡UponreturnfromsubroutineCOMMANDSregisterA6‚must‚be‚preserved.K*‚In‚fact,‚asastandardpracticethroughouttheentireoperatingsystemwe*‰PAGEJ*‚alwaysmaintainA6asapointertotheTCBforthetask‚that‚called‚uponI*‚the‚operating‚system‚toperformanoperation.‚IfasystemcrashsomehowJ*‚occurs,registerA6canprovideacluetotheenvironmentat‚the‚time‚of *‚thecrash.*G*‡Besides‚preservingregisterA6,subroutineCOMMANDSmustputastatusG*‚codeintoD0.B(i.e.,the‚least-significant‚byte‚of‚register‚D0)‚uponI*‚return‚to‚the‚callingroutine.‚IfsubroutineCOMMANDSprocessestheI/OK*‚requestwithoutfindinganyerrors,thesubroutinereturnscontrol‚to‚theK*‚calling‚routinewithD0.B=0toindicatethatalliswell.‚IfsubroutineM*‚COMMANDSdiscoversanerror,however,thesubroutinereturnscontroltotheF*‚calling‚routine‚with‚a‚nonzero‚error‚code‚inD0.BtoindicatethataI*‚problemhasbeenencountered.‚SubroutineCOMMANDSuses‚a‚unique‚nonzeroM*‚errorcodeforeachparticularerrorthatthesubroutinecandetect,sotheI*‚usercandeterminetheexactnatureofaproblem‚by‚examining‚the‚errorJ*‚code‚that‚subroutineCOMMANDSreturnsinD0.B.‚AcompletelistofallofM*‚theerrorcodesandtheirmeaningsisavailableelsewhereinthelistingof*‚theA/Ddriver.*H*‡AzerostatuscodeinD0.BindicatesonlythatsubroutineCOMMANDShasK*‚processedtheusertask'sI/Orequestwithoutdetectinganyerrors,‚and‚aL*‚zero‚statuscodedoesnotnecessarilyindicatethattheI/OactivitiesforK*‚theI/Orequesthavebeencompletedwithoutanyerrors.‚SomeI/O‚requestsM*‚causesubroutineCOMMANDStosetupsequencesofI/OoperationsthataretoK*‚beperformedoveranextendedperiodoftime.‚Incaseslikethese,a‚zeroL*‚status‚codethatisreturnedinD0.BbysubroutineCOMMANDSindicatesonlyF*‚thatthesubroutinehasprocessedthe‚I/O‚request‚and‚has‚set‚up‚theI*‚sequences‚of‚I/O‚operationswithoutdetectinganyerrors.‚AzerostatusK*‚codeinsuchacasedoesnotindicatethatanyoftheI/O‚operations‚haveH*‚been‚completed‚successfully,‚and‚the‚I/Ooperationscouldcauseerrors *‚laterwhentheyareperformed.*C*‡Besidesreturningastatuscode‚in‚D0.B,‚subroutine‚COMMANDS‚alsoI*‚returns‚the‚same‚status‚codeinthestatusfieldoftheusertask'sI/OH*‚commandblock.‚TheI/Ocommandblockisthe‚parameter‚block‚that‚tellsL*‚subroutine‚COMMANDSexactlywhattheusertaskwantsthedrivertodo,andL*‚thelayoutoftheI/Ocommandblockisdefinedelsewhereinthelisting‚of*‚theA/Ddriver.*C*‡In‚addition‚to‚preserving‚A6‚andreturningastatuscodeinD0.B,M*‚subroutineCOMMANDSmust,ofcourse,preservetheSPandthesystembyteofH*‚the‚SR.ƒAll‚other‚registersmaybemodifieduponreturntothecalling *‚routine.*F*‡SubroutineCOMMANDSperformsthecommontasksthatare‚necessary‚for H*‚all‚command‚routines,‚and‚then‚thesubroutineusesacommandswitchingL*‚tabletodirectcontroltotheindividualroutinethatprocessesthe‚givenE*‚command.ƒIf‚the‚command-code‚value‚in‚the‚I/Ocommandblockdoesn'tI*‚designateavalidcommand,subroutineCOMMANDSreturns‚an‚error‚code‚inM*‚D0.B(andinthestatusfieldoftheusertask'sI/Ocommandblock)totell,*‚theusertaskthatthecommandisinvalid.*‰PAGEG*‡Thetablebelowsummarizesthegeneralusageofregistersinthe‚partC*‚of‚subroutine‚COMMANDS‚that‚is‚common‚to‚all‚command‚routines.‚InM*‚particular,thefinalvaluesthatareshownbelowareintheregisterswhenE*‚control‚branches‚from‚the‚common‚part‚of‚subroutine‚COMMANDStothe4*‚individualroutinethathandlesthegivencommand.*F*‚#&A6=LOC(TCBofthetaskthatinvokedCMR).„#=Entrycondition.-*‚#&A5=LOC(CCB).¡&=Preservedonreturn.#*†A4=LOC(CMD_CODEfieldinIOCB).*†A3=LOC(DUPETBL).?*‚#ƒA2=LOC(CMRParameterBlock)initially.‚ThenLOC(MSBDATA).6*†A1=LOC(CNFIELDinIOCB)iftheIOCBhasaCNFIELD.*†A0=Scratch.* *†D6.L=0.D*†D5.L=NumberofwordsinIOCBafterCMD_CODEfield.‚AlsoinD4.L.D*†D4.L=NumberofwordsinIOCBafterCMD_CODEfield.‚CopyofD5.L. *†D3.L=0.*†D2.L=Scratch.C*†D1.L=Scratch.‚Controloffsetforthechannelbeinginitialized.+*†D0.B=STATNSNG(fortheMEAS_Scommand).**B*‡Theindividualcommand-processing‚routines‚all‚use‚a‚common‚exitG*‚routine‚to‚ensure‚a‚uniform‚return‚conditionforsubroutineCOMMANDS.J*‚SubroutineCOMMANDSpreservesA6,A5,theSP,andthesystem‚byte‚of‚theJ*‚SR,‚and‚the‚subroutinereturnsitsstatuscodeinD0.BandinthestatusE*‚fieldoftheusertask's‚I/O‚command‚block.ƒAll‚other‚registers‚areK*‚subject‚to‚modificationandmaycontainmeaninglessvaluesuponreturnto*‚thecallingroutine.*C*‡Notewithcarethattheprocessoris‚at‚interrupt‚level‚zero‚whenM*‚subroutineCOMMANDSreceivescontrol,sosubroutineCOMMANDSandallofitsG*‚subordinateroutinesare‚subject‚to‚interrupts‚from‚the‚periodically-L*‚activated‚measurementroutineand/orfromthecompletionofanexternally-K*‚triggeredmeasurement.‚Theperiodically-activatedmeasurementroutine‚andK*‚the‚A/D‚interrupthandlermayaccessand/orchangevaluesintheCCB,andE*‚subroutineCOMMANDSmustbecarefullycodedwiththisfactinmind.  ?COMMANDSMOVE.LƒSP,SAVE_SP(A5)‰Savethe‚stack‚pointer‚so‚we‚can$*¦later‚abort‚at‚any‚level‚ofnested$*¦subroutines‚and‚easily‚restoreƒthe%*¦stack‚environment‚that‚existed‚when*¦thisroutinebeganexecution.-‰PAGEš#######################################2‰MOVE.LƒA5,A4’Set‚A4<--LOC(CCB)toindicatethat%*¦A4doesn't‚yet‚contain‚the‚physical)*¦memoryaddressoftheCMD_CODEfieldof'*¦theuser'sIOCB.‚SincetheIOCB‚can't)*¦possiblybeatthesamephysicalmemory(*¦locationwheretheCCBresides,we‚can'*¦later‚compare‚A4toA5tofindoutif)*¦A4hasbeensettocontainthephysical)*¦memoryaddressoftheCMD_CODEfieldof&*¦theuser'sIOCB.‚AslongasA4‚=‚A5,)*¦weknowthatA4doesn'tyetcontainthe&*¦addressoftheCMD_CODE‚field‚of‚the'*¦IOCB.ƒAfterA4=LOC(CMD_CODE[IOCB]),(*¦we'llbeabletouseA4toaddress‚the&*¦user's‚IOCB.ƒInparticular,we'llbe$*¦abletoaccess‚the‚IOCB‚to‚store‚a&*¦status‚code‚into‚theSTATUSfieldof *¦theIOCB. "*¨Thisstep‚and‚the‚next‚two‚steps%*¦should‚be‚done‚in‚orderwithnonew%*¦interveningsteps.ƒThe‚code‚remains(*¦sensitive‚untilA4hasbeensettoits#*¦finalvalue,LOC(CMD_CODE[IOCB]). 8‰MOVE.LƒXIOCPK(A2),D6ŠGetthephysical‚memory‚address‚of0‰MOVEQ.L‚#0,D5the‚IOCB‚for‚the‚command‚into‚A4.<‰MOVE.WƒXIOPLN(A2),D5ˆSubroutineLOGPHYconvertsthe‚logical2‰BSR†LOGPHYIOCB‚address(inD6.L)intoaphysical2‰MOVE.LƒD6,A4addressforus.‚Wemust‚call‚subrou-$*¦tine‚LOGPHY‚with‚A6‚containing‚the )*¦physicaladdressoftheTCBofthetask(*¦that‚ownstheIOCB,andwemustsetup'*¦D5.Ltospecifythelength‚(in‚bytes)(*¦oftheIOCB.‚Ifallgoeswell,subrou-)*¦tineLOGPHYreturnsthephysicalmemory*¦addressoftheIOCBinD6.L. %*¨Subroutine‚LOGPHY‚abortsprocessing$*¦iftheIOCB‚that‚we‚specify‚is‚not'*¦entirely‚within‚amemorysegmentthat)*¦belongstothetaskthatownstheIOCB.(*¦If‚thiserroroccurs,thefactthatwe(*¦setA4=A5abovewillpreventus‚from'*¦trying‚to‚storeastatuscodeintoan#*¦IOCBthatdoesn'tproperlyexist. #*¨Wemust‚execute‚one‚more‚critical(*¦step‚tosetA4toitsfinalvalue,and&*¦thenthissequence‚of‚critical‚steps*¦willbecomplete.-‰PAGEš#######################################3‰MOVEQ.L‚#0,D6’ClearD6.Lforgeneraluse,and‚then8‰MOVE.WƒD6,(A4)+initializetheSTATUSfieldoftheIOCB3LˆSET†STATUStozero.‚We'lllaterupdatetheleast-)*¦significantbyteoftheSTATUSfieldto(*¦reflecttheactualstatuscodethat‚we*¦wanttoreturntotheuser. %*¨As‚we‚cleartheSTATUSfieldofthe(*¦IOCBhere,wesimultaneouslysetA4‚to(*¦contain‚thephysicalmemoryaddressof(*¦theCMD_CODEfieldoftheIOCB.‚Nowwe&*¦can‚safely‚use‚A4withautodecrement%*¦addressingtoupdate‚the‚LSB‚of‚the*¦STATUSfieldintheIOCB. "*¨Thisƒstep‚completes‚the‚critical&*¦sequenceofthreesteps‚that‚must‚be'*¦done‚in‚orderwithnointerveningnew"*¦steps.ƒNow‚we‚can‚safely‚use‚the)*¦commonexitroutinewheneverwewantto *¦exitfromsubroutineCOMMANDS. 7‰MOVEQBƒSTATCBLN,D0ŒIfthespecifiedlengthof‚the‚IOCB:‰SUBQ.Lƒ#IOCB_MIN,D5‰is‚shorter‚thantheminimumallowable4‰BLO.S„CMDEXIT2lengthforan‚IOCB,‚abort‚processing-‰LSR.L„#1,D5andƒreturnƒan‚error‚status‚code.5‰MOVE.LƒD5,D4Otherwise,setbothD5.LandD4.Lequal$*¦to‚the‚number‚of‚words‚(notbytes)(*¦remainingintheIOCBaftertheend‚of(*¦theCMD_CODEfield.‚We'lllateruseD5(*¦andD4ascounterswhenweprocess‚the(*¦remainingfields(ifany)oftheIOCB. 8‰MOVEQBƒISTACDN,D0IftheA/Dchannelisdown,goreturn7‰TST.B„AD_DOWN(A5)Šanerrorstatusto‚indicate‚that‚the5‰BNE.S„CMDEX2AŽA/D‚channelisoutofservicefornow.$*¦Although‚we‚could‚process‚OPEN‚and(*¦CLOSE‚commandsforadeadA/Dchannel,&*¦wechoosetoreject‚all‚A/D‚commands*¦forthesakeofconsistency.-‰PAGEš#######################################1‰TST.B„BAD_INT(A5)ŒIf‚we‚have‚receivedƒaƒspurious0‰BEQ.S„L9“interrupt‚fromtheA/Dconverterboard(*¦andhaven'tyetreportedit,clear‚the8‰CLR.B„BAD_INT(A5)Šbad-interrupt‚flag,‚abortthecurrent4‰MOVEQBƒSTATBINT,D0Šcommand,‚andƒreportƒtheƒspurious‚32,767‚(i.e.,‚$7FFF)&*¦because‚the‚processor‚interpretsthe(*¦valueinD2.Wasasignednumber‚here.&*¦We‚could‚easily‚avoidthispotential'*¦errorbyaddingjust‚one‚instruction,(*¦but‚theoffsetvalueinD2.Wisnotat'*¦alllikelytoexceed32,767.‚The‚size&*¦of‚the‚entire‚driver(initsinitial)*¦release)issmallerthan$500bytes,so&*¦an‚offset‚in‚excessof32,767isnot'*¦possibleunlessthedriver‚changes‚by"*¦morethananorderofmagnitude.+‰TTL†5.2.1.‚OPEN_CMDRoutine(OPENCommand)-‰PAGEš#######################################N*******************************************************************************Ì*@*ˆTheremainingpartofthisprogramisnotcommentedyet.‚Any‡*A*ˆcommentsthatexistbeyondthispointarescratchcommentsor‡**ˆpreliminarycomments.¯**Ì*N****************************************************************************** 4*ˆOPENCommand.‚ControlentersatlocationOPEN_CMD. %*†#A6=LOC(TCBofrequestingtask).*†#A5=LOC(CCB).%*†#A4=LOC(CMD_CODEfieldinIOCB).*†#A3=LOC(DUPETBL).*†#A2=LOC(MSBDATA).*†#A1=LOC(CNFIELDinIOCB)./*ˆA0=LOC(Channelblockforselectedchannel). *ˆD7.L= *†#D6.L=0.2*†#D5.L=NumberofwordsafterCMD_CODEinIOCB.2*†#D4.L=NumberofwordsafterCMD_CODEinIOCB. *†#D3.L=0.*ˆD2.L=Scratch.*ˆD1.L=Scratch.*ˆD0.L=Scratch.  8L12†BSR†VALID_CNValidatenextchannelnumber,andpoint'*¦A0toitschannelblock.‚Alsoadvance'*¦A1topointtofollowingchannelnum. ‰MOVEQBƒSTATOPEN,D0'‰TST.L„TCB_ADDR(A0)‰Isitalreadyopen?,‰BNE.S„CMDEXIT2Error:‚Channelalreadyopen. 7OPEN_CMDDBRA…D5,L12Loopuntilallchannelsprocessed. ,‰BRA.S„L14’Noerrorsinanychannelnumbers.     ,L13†MOVE.Wƒ-(A1),D1Getnextchannelnumber. LˆSET†CNFIELD(‰BSR†CNLBLKADPointA0tochannelblock.9‰MOVE.LƒA6,TCB_ADDR(A0)†Openchannelforrequestingtask./L14†DBRA…D4,L13Loopuntilallchannelsopened.‰TTL†5.2.2.‚CommonExitRoutine-‰PAGEš#######################################?*ˆCommonexitroutine.‚Controlfallsinfromaboveinonecase. %*†#A6=LOC(TCBofrequestingtask).*†#A5=LOC(CCB).1*†#A4=LOC(CMD_CODEfieldinIOCB)orLOC(CCB). &*ˆSTATUSwordinIOCBiszeroalready. /CMDEXIT1MOVEQBƒISTAOK,D0ŒD0.B<--Statuscode.    ,*ˆSecondentrypointtocommonexitroutine. *†#D0.B=Statuscode. 8CMDEXIT2CMP.L„A4,A5’IfA4=A5,thenA4hasn'tyetbeen2‰BEQ.S„CMDEXIT3settocontainthephysicalmemory&*¦addressoftheCMD_CODEfieldofthe&*¦IOCB.‚Inthiscase,wehaveprobably)*¦abortedprocessingbecausetheIOCBwas(*¦improperlyspecified,andweobviously$*¦can'tstoreastatuscodeintothe"*¦STATUSfieldoftheerroneously-#*¦specifiedIOCB.‚Thecheckthatwe(*¦performherepreventsusfrommakinga&*¦wildstoreintoarandomlocationof *¦memory. 3‰MOVE.BƒD0,-(A4)Putthe8-bitstatuscodeintothe1LˆSET†STATUSleast-significantbyteoftheSTATUS(*¦wordintheIOCB.‚Themost-significant)*¦byteoftheSTATUSwordiszerobecause'*¦wecleareditatthebeginningofthe *¦command-processingsubroutine. DCMDEXIT3MOVE.LƒSAVE_SP(A5),SP‰Restorethestackpointer,andreturn'‰RTS›controltotheroutinethatcalled&*¦subroutineCOMMANDS.‚Thestatuscode(*¦isinD0.Basrequired.‚Noticethatwe&*¦canusethisreturnroutinetoabort&*¦processingfromanylevelwithinthe$*¦commandserviceroutinebecausewe(*¦restorethestackpointertothevalue&*¦thatithadwhensubroutineCOMMANDS$*¦beganexecutionatitsmainlevel. #*¨Ourhandlingofthestackpointer'*¦appearstoeliminatere-entrancy,but'*¦theA/Ddriverisstillre-entrantin'*¦thenecessarycontextbecausesubrou-%*¦tineCOMMANDScanneverbecalleda(*¦secondtimefromausertaskexecuting)*¦atinterruptlevelzerountilwereturn*¦controlfromthefirstcall. $*¨SubroutineCOMMANDScanacceptre-'*¦entrantcallsforanotherA/Dchannel'*¦becauseeachchannelhasitsownCCB.+‰TTL†5.2.3.‚STOP_CMDRoutine(STOPCommand)-‰PAGEš#######################################?*ˆCLOSECommandandSTOPCommand.‚Firstpartiscommontoboth. %*†#A6=LOC(TCBofrequestingtask).*†#A5=LOC(CCB).*†#A4=LOC(CMD_CODEinIOCB).*†#A3=LOC(DUPETBL).*†#A2=LOC(MSBDATA).*†#A1=LOC(CNFIELDinIOCB)./*ˆA0=LOC(Channelblockforselectedchannel). *ˆD7.L=4*†#D6.L=0.‚WesetD6.L<---1foraSTOPcommand.2*†#D5.L=NumberofwordsafterCMD_CODEinIOCB.2*†#D4.L=NumberofwordsafterCMD_CODEinIOCB. *†#D3.L=0.*ˆD2.L=Scratch.*ˆD1.L=Scratch.*ˆD0.L=Scratch. :STOP_CMDMOVEQ.L‚#-1,D6SetflagtoindicateSTOPcommand. ,‰TTL†5.2.4.‚CLOSECMDRoutine(CLOSECommand)5CLOSECMDTST.L„D5“D5=0ifnochannelsspecified.‚In/‰BNE.S„L19’thiscasewecloseallopenchannels'*¦forthistask.‚Fallthroughtomakea)*¦listofallchannelsopentothistask.  L15†EQU†(MAXCNLS-1)*CNLBLKSZ6‰LEA†CNLBLK+L15(A5),A0„PointA0tolastchannelblock.7‰MOVEQWƒMAXCNLS-1,D0‰Channelnumberoflastchanneland *¦channelcounttocontrolloop.  *ˆFirstpassthroughthechannelblock(s)oftheIOCBforboth1*ˆsingle-endedanddifferentialMEASUREcommands. %*†#A6=LOC(TCBofrequestingtask).*†#A5=LOC(CCB).*†#A4=LOC(CMD_CODEinIOCB).*†#A3=LOC(DUPETBL).@*ˆA2=LOC(Currentfieldinchannelblockforselectedchannel).**†#A1=LOC(FirstchannelblockinIOCB)./*ˆA0=LOC(Channelblockforselectedchannel). *ˆD7.L=%*ˆD6.L=Scratch.‚AddressforLOGPHY.'*ˆD5.L=ScratchƒBytecountforLOGPHY.I*†#D4.L=NumberofwordsafterbeginningoffirstchannelblockinIOCB*>0.+*†#D3.L=+0forsingle-endedmeasurement."*-1fordifferentialmeasurement.I*†#D2.L=NumberofwordsafterbeginningoffirstchannelblockinIOCB*>0.B*ˆD1.L=Scratch.‚Weuseitforchannelnumberofcurrentchannel.*ˆD0.L=Scratch.  @MEAS_LP1SUBQ.Wƒ#CHNBLKSZ/2,D2‰IftheremainingpartoftheIOCB1‰BHS.S„L23’containsenoughwordstoaccommodatea)*¦fullchannelblock,goprocessthenext*¦channelblock. :‰ADDQ.Wƒ#CHNBLKSZ/2,D2‰Ifwe'vefinishedprocessingallof3‰BEQ.S„MEAS_PS2thewordsoftheIOCB,gostartthe!*¦secondpassthroughthechannel*¦block(s)oftheIOCB. '*¨Otherwise,wehaveanIOCBthatisn't)*¦formattedcorrectlysinceitcontainsa&*¦partialchannelblockatitsend.‚In(*¦thiscase,controlfallsintothenext'*¦routine,whichreportsanIOCBerror. AIOCB_ERRMOVEQBƒSTATIOCB,D0ŒGetthestatuscodethatindicatesan&*¦IOCBthatisn'tcorrectlyformatted.)*¦We'vefoundthatthelengthoftheIOCB&*¦doesn'tmatchupwiththepredefined&*¦IOCBtemplateforaMEASUREcommand. 6MEAS_ERRBRA†CMDEXIT2AbortprocessingfortheMEASURE'*¦command,andreporttheerrorthatis'*¦indicatedbythestatuscodeinD0.B.%*¦Controlbranchestothiserrorexit)*¦fromseveraldifferentplacestoreport*¦varioustypesoferrors. 6L23†MOVEQ.L‚#0,D6’ClearD6.Ltoindicatethatwedon't5‰BSR†VALIDATEallowthespecifiedmeasurementchannel(*¦tobepreviouslyactive,andthencall%*¦subroutineVALIDATEtovalidatethe)*¦channelnumberthatisaddressedinthe'*¦IOCBbyA1.‚SubroutineVALIDATEmakes(*¦severalvaliditychecksonthechannel'*¦number,anditabortsprocessingwith'*¦anerrorreportifitfindsanerror.(*¦IfsubroutineVALIDATEdoesn'tfindan)*¦error,itreturnsthespecifiedchannel&*¦numberinD1.W.‚Also,thesubroutine(*¦advancesA1topointtothenextfield'*¦ofthechannelblockintheIOCB,and'*¦itpointsA0totheCCBchannelblock(*¦forthespecifiedmeasurementchannel. 7‰LEA†CNL_CMPL(A0),A2ˆPointA2tothechannel-completion(*¦fieldoftheCCBchannelblockforthe&*¦specifiedmeasurementchannel.‚We'll)*¦useA2withautoincrementaddressingto)*¦accessseveralofthefieldsintheCCB*¦channelblock. %*¨We'llsavethepointertothefirst&*¦byteoftheCCBchannelblockinA0.&*¦Attheendofthefirstpassthrough&*¦thechannelblock(s)oftheIOCB,A0)*¦willpointtotheCCBchannelblockfor(*¦thelastmeasurementchannelselected,)*¦andwe'llusethatpointervalueduring)*¦thefirstiterationofthesecondpass. ‰MOVE.Wƒ(A1)+,D0 LˆSET†CHN_CMP‰MOVE.WƒD0,(A2)+LˆSET†CNL_CMPL ‰ROL.B„#7-SUBR_B,D0 ‰BPL.S„L24 1‰SUBQ.Wƒ#2,D22wordsforthesubroutineaddress.‰BLO.S„IOCB_ERR ‰MOVE.Lƒ(A1)+,D6 LˆSET†SUBRTNE6‰MOVEQ.L‚#2,D5Minimumpossiblelengthforsubroutine. ‰BSR†LOGPHY 0L24†MOVE.LƒD6,(A2)+Physicalsubroutineaddress. LˆSET†SUBRTN ‰MOVE.Lƒ(A1)+,D6 LˆSET†BUFFER‰MOVE.Wƒ(A1)+,D5 LˆSET†BUFSZ ‰BSR†LOGPHY‰MOVE.LƒD6,(A2)+LˆSET†BUF_ADDR ‰CLR.W„(A2)+LˆSET†BUF_PNTR ‰MOVEQBƒEXTTRG+PGA,D0.‰AND.W„(A1)+,D0Ignoreallbutthosetwobits.LˆSET†TRIGGAIN ‰AND.B„#MUX+CNLSEL,D1‰ADDQ.Bƒ#MUX07,D1 ‰OR.B…D1,D0 ‰MOVEQBƒMUX815+MUX07,D14‰AND.B„D3,D1D3=$FFIFDIFFERENTIAL,$00ifsingle ‰OR.B…D1,D0 ‰MOV E.BƒD0,(A2)+LˆSET†CTRL_VAL ‰ROL.B„#7-EXTTRG_B,D0‰BPL.S„MEAS_LP1 ‰ST.B…ET_FLG_S(SP) ‰TST.B„MEAS_CNT(A5)‰BEQ.S„MEAS_LP1 ‰MOVEQBƒSTATBUSY,D0‰BRA.S„MEAS_ERR4‰TTL†5.2.5.3.‚SecondPassthroughtheChannelBlocks-‰PAGEš#######################################?*ˆSecondpassthroughthechannelblock(s)oftheIOCBforboth1*ˆsingle-endedanddifferentialMEASUREcommands. %*†#A6=LOC(TCBofrequestingtask).*†#A5=LOC(CCB).*†#A4=LOC(CMD_CODEinIOCB).5*†#A3=LOC(DUPETBL).‚Availableforscratchusenow.*ˆA2=;*ˆA1=LOC(CurrentfieldofcurrentchannelblockinIOCB).E*†#A0=LOC(Channelblockforselectedchannel).‚Initiallypointsto>*CCBchannelblockforlastselectedmeasurementchannelfrom *firstpass. *ˆD7.L=*ˆD6.L=Scratch.*ˆD5.L=ScratchI*†#D4.L=NumberofwordsafterbeginningoffirstchannelblockinIOCB*>0.+*†#D3.L=+0forsingle-endedmeasurement."*-1fordifferentialmeasurement.*ˆD2.L=Scratch.B*ˆD1.L=Scratch.‚Weuseitforchannelnumberofcurrentchannel.*ˆD0.L=Scratch.  "MEAS_PS2MOVE.Bƒ(SP)+,EXT_TRIG(A5)LˆSET†ET_FLG_S‰ADDQ.Bƒ#1,MEAS_CNT(A5)8‰MOVE.Lƒ(SP)+,A1PointA1tofirstchannelblockinIOCBLˆSET†CBADDR_S MEAS_LP2MOVE.Wƒ(A1)+,D1 LˆSET†CHN_NUM>‰MOVE.BƒD1,CNL_PTR(A0)‡Pointpreviouschannelblocktocurrent‰BSR†CNLBLKADone. ‰MOVE.Wƒ(A1)+,D0 LˆSET†CHN_CMP‰ROL.B„#7-SUBR_B,D0 ‰BPL.S„L25 +‰SUBQ.Wƒ#2,D42WORDSFORSUBROUTINEFIELD.+‰ADDQ.Lƒ#4,A14BYTESFORSUBROUTINEFIELD. L25†EQU†*L26†EQU†BUFSZ-BUFFERC‰MOVE.WƒL26(A1),BUF_SIZE(A0)Themeasurementchannelisnowactive. ‰ADDQ.Lƒ#CHNBLKSZ-BUFFER,A1 ‰SUBQ.Wƒ#CHNBLKSZ/2,D4‰BHI.S„MEAS_LP2"‰TTL†5.2.5.4.‚FinalCommandSet-Up-‰PAGEš#######################################F*ˆNowsetupthecommandvariablesinthechannelblockforthemaster*‚measurementchannel.  4‰MOVE.BƒCNL_PTR(A0),D1‡TophalfofD1.W=0already.'‰BSR†CNLBLKADPointA0totopofchain.‰LEA†CNL_PTR(A0),A2 3‰TAS.B„(A2)+Marktopofchainbysettingsignbit. LˆSET†CNL_PTR ‰MOVE.Wƒ(SP)+,(A2)+ LˆSET†COMPL_SLˆSET†CMD_CMPL ,‰MOVE.Lƒ(SP)+,A1Delta-T-->A1.‚(ForRQPA).LˆSET†DELTAT_S ‰MOVE.Wƒ(SP)+,D1 LˆSET†R_CNT_S‰MOVE.WƒD1,(A2)+ LˆSET†RPT_CNT ‰MOVE.LƒA4,(A2)+LˆSET†IOCB_ADR 1‰ST.B…(A2)+’Settheflagthatsayswehaven'tyet3LˆSET†NORQPArequestedaperiodicactivationofthe$*¦periodically-activatedmeasurement'*¦routineforthiscommand.‚We'lllater&*¦cleartheNORQPAflagifwesuccess-(*¦fullyrequestaperiodicactivationof(*¦theperiodically-activatedmeasurement*¦routineforthiscommand. 2‰MOVE.WƒSR,D0’GettheSRvalueintoD0.W,andsave6‰MOVE.WƒD0,-(SP)acopyofitonthestacksowe'llbe&*¦abletorestorethepresentSRvalue*¦later. =‰AND.W„#$FFFF-INT_MASK,D0…Cleartheinterrupt-levelbitsfrom8‰OR.W…CCBISR(A5),D0ˆtheSRvalue,andsettheinterrupt-2‰MOVE.WƒD0,SRlevelbitstotheinterruptlevelof'*¦theA/Dconverterboard.‚Thenputthe&*¦updatedSRvalueintotheSRtomask&*¦interruptsattheleveloftheboard&*¦withoutchanginganyoftheotherSR$*¦bits.‚Wetakeextrastepstoavoid&*¦changinganyoftheSRbitsthatare&*¦presentlyundefinedbecausethoseSR$*¦bitsmighthavemeaningsinfuture!*¦processorsinthe68000family. #*¨Wemustmaskinterruptsbeforewe'*¦issuetheRQPAexecutiverequest(see%*¦below)sowecanguaranteethatthe$*¦periodically-activatedmeasurement&*¦routinewon'tbeactivatedbeforewe$*¦performthefirstexectuionofthe&*¦measurementroutineourselves.‚Also,#*¦interruptsmustbemaskedwhenwe)*¦executethemeasurementroutinebecause'*¦themeasurementroutinehasnowayto*¦maskinterruptsattheboard. ‰SUBQ.Wƒ#1,D1+‰BEQ.S„L28’Repeatcount=1.ƒTheIMMEDflag *¦doesn'tmatterifRPT_CNT=1. #‰MOVE.LƒA1,D0TestDelta-T(inA1).%‰SEQ.B„(A2)‘A2remainsatLOC(IM MED). LˆSET†IMMED‰BEQ.S„L28’DeltaT=0. 1‰MOVE.LƒA0,D2D2<--LOC(CNLBLKinCCB)forRQPA.!‰LEA†MEAS_PA(PC),A0‡LOC(ROUTINE). ACTIVATEEQU†0<<15REPEATƒEQU†1<<14‰MOVEQWƒACTIVATE+REPEAT,D1‰MOVE.BƒCCBPPRIO(A5),D1‰MOVE.Lƒ#T0RQPA,D0‰TRAP…#EXECDestroysD0,D1.‰BRA.S„L27’OK. )‰MOVE.LƒD2,A0NotOK.‚LOC(CNLBLK)-->A0.*‰BSR†STOP1Stopmeasurementsjuststarted. ‰MOVEQBƒSTATRQPA,D0‰BRA.S„L29’GotoCMDEXIT2. 5L27†CLR.B„-(A2)’We'vesuccessfullyrequestedperiodic,LˆSET†NORQPAactivationoftheperiodically-(*¦activatedmeasurementroutineforthis'*¦command,socleartheNORQPAflag.‚By&*¦clearingtheNORQPAflagweindicate%*¦thatthereisaperiodicactivation)*¦activeforthiscommand,andwe'llknow'*¦tostopthatperiodicactivationwhen(*¦wecomplete(orstop)themeasurements*¦forthecommand. !‰MOVE.LƒD2,A0LOC(CNLBLKinCCB). =L28†MOVEQ.L‚#T0QEVNTT,D6‹Getthecodethatweuseforqueuing$*¦aneventfromaroutinethatisn't)*¦beingexecutedasaninterrupthandler. 1‰BSR.S„MEAS_RTNCallthemeasurementroutine.‚The&*¦measurementroutinereturnsastatus*¦valueinD0.W. #L29†MOVE.Wƒ(SP)+,SRRestoretheSR. ‰BRA†CMDEXIT2,‰TTL†5.2.5.5.‚MEAS_RTN(MeasurementRoutine)-‰PAGEš#######################################D*ˆInterruptsmustbemaskedthroughoutthisroutine.‚Thisroutineis*ˆnotre-entrant. *†#A5=LOC(CCB).*ˆA3=LOC(BUFFER).*ˆA2=LOC(MSBDATA).*ˆA1=Scratch.#*†#A0=LOC(ChannelblockinCCB). *†#D6.L=T0QEVNTIorT0QEVNTT.*ˆD5.W=Statuscode.*ˆD4.L=ScratchinSTOP1.*ˆD3.B=ScratchinSTOP1. *ˆD2.B=CTRL_VAL(A0)initially.1*ˆD2.L=Bufferoffsetlater.‚(Tophalfiszero.)3*ˆD1.W=Measurementresult;later,channelnumber.**ˆD0.L=Scratch.‚D0.W=Statusonreturn.  MEAS_RTNMOVE.LƒCCBCHB(A5),A2 >MEAS_NXTMOVEQ.L‚#0,D1We'lldependonbyte1ofD1beingzero5‰MOVE.BƒCTLOFFST(A0),D1†bothhereandlater(atL52).9‰MOVE.BƒCTRL_VAL(A0),D2†GetCTRL_VALandkeepitinD2.B.2‰MOVE.BƒD2,CONTROL(A2,D1.W)‚Startthemeasurement. L43†EQU†8+10‘Cyclesperloop.D1.W.‰MOVE.LƒBUF_ADDR(A0),A3‰MOVEQ.L‚#0,D2‰MOVE.WƒBUF_PNTR(A0),D27‰MOVE.WƒD1,0(A3,D2.L)ˆResult-->buffer.‚WeuseD2.Lto*¦avoidsignextensionofD2.W. ‰MOVE.WƒCNL_CMPL(A0),D0‰BTST.Lƒ#SUBR_B,D0‰BEQ.S„L48’Nosubroutine. ‰MOVE.LƒSUBRTN(A0),A1‰JSR†(A1)‘Callthesubroutine. L48†ADDQ.Wƒ#2,D2‰CMP.W„BUF_SIZE(A0),D2 ‰BLO.S„L49‰MOVEQ.L‚#0,D21L49†MOVE.WƒD2,BUF_PNTR(A0)†Updatebufferpointer. *‰BSR.S„WAKEUPIssuewakeupifappropriate. ‰MOVEQ.L‚#MEAS_TYP,D2 ‰BSR.S„QEVENT ‰MOVEQ.L‚#CP_MASK,D1‰AND.B„CNL_PTR(A0),D1-‰BSR†CNLBLKADPointA0tonextchannelblock. ‰TST.B„CNL_PTR(A0)!‰BPL†MEAS_NXTNotmasterchannel.  ‰MOVEQ.L‚#0,D5Goodstatus. ‰TST.W„RPT_CNT(A0)‰BEQ.S„L50’0=infinity. ‰SUBQ.Wƒ#1,RPT_CNT(A0) ‰BEQ.S„L53 L50†TST.B„IMMED(A0)!‰BNE†MEAS_NXTRepeatimmediately.-‰BRA.S„L55’Returnwithgoodstatus.‚We'llget&*¦activatedagainbythenextperiodic *¦activation.  L51†BSR†CNLBLKAD@L52†MOVE.BƒCNL_PTR(A0),D1‡Byte1ofD1=0alreadyfromearlier. ‰BPL.S„L51 L53†MOVE.WƒCMD_CMPL(A0),D0,‰BSR.S„WAKEUPIssueawakeupifappropriate. ‰MOVEQ.L‚#CMPL_TYP,D2 ‰MOVE.WƒD5,D1 ‰BSR.S„QEVENT ‰LSR.W„#EVENT_B+1,D0 ‰BCS.S „L54 ‰MOVE.LƒIOCB_ADR(A0),A1‰MOVE.WƒD5,-(A1) LˆSET†STATUS L54†BSR.S„STOP1 L55†MOVE.WƒD5,D0‰RTS‰TTL†5.2.5.6.‚SubroutineWAKEUP-‰PAGEš#######################################*ˆSubroutineWAKEUP ;*†#A0=LOC(Channelblockforcurrentmeasurementchannel) *†#D0.W=completioncode. +*ˆWepreserveallregistersexcepttheCCR.  WAKEUPƒEQU†*WU_REGS‚REG†A0/D0‰MOVEM.L‚WU_REGS,-(SP) ‰LSR.W„#WAKEUP_B+1,D0 ‰BCC.S„L56 ‰MOVEQ.L‚#T0WAKEUP,D0‰MOVE.LƒTCB_ADDR(A0),A0 ‰TRAP…#EXEC L56†MOVEM.L‚(SP)+,WU_REGS‰RTS‰TTL†5.2.5.7.‚SubroutineQEVENT-‰PAGEš#######################################*ˆSubroutineQEVENT *†#A5=LOC(CCB).*†#A0=LOC(ChannelBlock). "*†#D6.L=ExecutiveRequestCode.*†#D2.L=Eventtype.-*†#D1.W=Statuscodeormeasurementresult.*†#D0.W=Completionoption.  QEVENTƒEQU†* !QREGS„REG†D0-D3/D5-D7/A0-A1/A3-A5‰MOVEM.L‚QREGS,-(SP) ‰MOVE.WƒD0,D3Completionoption.‰LSR.W„#EVENT_B+1,D0‰BCC.S„L59’Noeventrequested. ‰SWAP…D30‰MOVE.WƒD1,D3Statuscodeormeasurementresult. ‰ROL.W„#8,D2 L57†EQU†ELENGTH<<24L58†EQU†ECODE<<16 ‰OR.L…#L57+L58+EDRVCD,D2 ‰MOVE.LƒD6,D0‰MOVE.LƒTCB_ADDR(A0),A0 ‰TRAP…#EXEC#‰NOP›Good.‚BRA.SL59inthefuture.)*ˆ—Bad.‚Fornow,justignorethat. L59†MOVEM.L‚(SP)+,QREGS‰RTS‰TTL†5.2.6.‚CommonSubroutines‰TTL†5.2.6.1.‚SubroutineSTOP-‰PAGEš#######################################6*ˆStopthemeasurementsspecifiedbytheSTOPcommand.-*ˆControlentersatSTOP2foraSTOPcommand.0*ˆControlentersatSTOP1foraMEASUREcommand.@*ˆInterruptsaremaskedattheleveloftheA/Dconverterboard. *†#A5=LOC(CCB).*ˆA3=-*†#A2=LOC(MSBDATA).‚WesetthisforSTOP1.*†#A1=LOC(lastCNFIELD)+2./*ˆA0=LOC(Channelblockforselectedchannel). *ˆD7.L=*ˆD6.L=*ˆD5.L=C*†#D4.L=NumberofwordsafterCMD_CODEinIOCB.‚Set0forSTOP1.H*†#D3.B=+0initiallytoindicatethatnoactiveMEASUREcommandshave*’beenstopped.:*Nonzerolaterifweactuallystopanactivemeasurement.;*InitiallyrandomforSTOP1.‚Weknowwe'llstopsomething.*ˆD2.L=Scratch.*ˆD1.L=Scratch.*ˆD0.L=Scratch.  6STOP1„MOVE.LƒSP,A1Topreventbuserroronaccesswith*¦-(A1). ‰MOVE.LƒCCBCHB(A5),A2*‰MOVEQ.L‚#0,D4Clearcountfornorepeats. 0L30†CLR.W„ACTIVE(A0)‹Markthischannelinactive. )‰MOVEQ.L‚#0,D1TocleartophalfofD1.W.<‰MOVE.BƒCNL_PTR(A0),D1‡Getchannelnumberofnextchannelin0‰BPL.S„L32’thisgroup.‚Branchunlessthecurrent&*¦channelisthemasterchannelofthe*¦group. 1‰MOVE.BƒD1,D3SavepointertonextchannelinD3.%*¦NoticethatD3.B<>0nowsincethe*¦signbitisset. 6‰TST.B„NORQPA(A0)Skipifthemeasurementsequencefor+‰BNE.S„L31’thiscommandwasn'tperiodically *¦activated. 3‰MOVEQ.L‚#-1,D1Bit15saysdeactivateroutine;all*¦otherbitsignored./‰MOVE.LƒA0,D2Pointertocurrentchannelblock.9‰MOVEQ.L‚#T0RQPA,D0‹CodeforRequestPeriodicActivation.,‰TRAP…#EXECRequestdeactivationofroutine.(‰NOP›Goodreturn.‚Nosuchthingasabad#*¦return,sowemergegoodandbad.*¦DestroysD0andD1.-‰PAGEš#######################################*†#D6.L=+0ifselectedchannelisnotallowedtobeactive.*-1otherwise.*ˆD5.L=*ˆD4.L=*ˆD3.L=*ˆD2.L="*ˆD1.W=ChannelNumberonreturn.*ˆD0.L=Scratch.  >VALIDATEBSR.S„VALID_CNValidatenextchannelnumberandpoint'*¦A0toitschannelblock.‚Alsoadvance*¦A1topointtonextword. ‰MOVEQBƒSTATNOPN,D08‰CMP.L„TCB_ADDR(A0),A6†Isthechannelopentothistask?#‰BNE.S„CMDEX2BŽNo.‚Reportanerror. )‰TST.L„D6“SkiptheactivetestforaSTOP‰BNE.S„L38’command. ‰MOVEQBƒSTATACTV,D04‰TST.W„ACTIVE(A0)‹Isthechannelactive(measuring)?4‰BNE.S„CMDEX2BŽYes.‚Reportanerror.‚Can'tcloseit. L38†RTS!‰TTL†5.2.6.3.‚SubroutineVALID_CN-‰PAGEš#######################################*ˆSubroutineVALID_CN *†#A5=LOC(CCB).%*†#A4=LOC(CMD_CODEfieldinIOCB).*†#A3=LOC(DUPETBL).9*†#A1=LOC(Channel-numberword).‚Incrementedonreturn.-*ˆA0=LOC(SelectedChannelBlock)onreturn. 9*ˆD1.W=ChannelNumberonreturn.‚OnentryforCNLBLKAD.*ˆD0.L=Scratch.  >VALID_CNMOVE.Wƒ(A1)+,D1GetnextchannelnumberintoD1.WandLˆSET†CNFIELDŽadvanceA1. LˆSET†CHN_NUM ‰MOVEQBƒSTAT0_95,D0‰CMP.W„#MAXCNLS-1,D1*‰BHI.S„CMDEX2BŽError:‚ChannelNumber>95. ‰MOVEQBƒSTATDUPE,D0‰TAS.B„0(A3,D1.W) LˆSET†DUPETBL6CMDEX2B‚BNE.S„CMDEX2CŽError:‚Duplicatechannelnumber. ‰TST.B„DIFF_F(A5)"‰BEQ.S„CNLBLKADSingle-endedmode. ‰MOVEQBƒSTATDIFF,D0‰BTST.Lƒ#MUX_BIT,D13‰BNE.S„CMDEX2CŽInvaliddifferentialchannelnumber. CNLBLKADLEA†CNLBLK(A5),A0‰MOVEQWƒCNLBLKSZ,D0 ‰MULU…D1,D00‰ADD.L„D0,A0PointA0toselectedchannelblock. ‰RTSH‚TTL„5.2.6.4.‚SubroutineLOGPHY(Logical-to-PhysicalAddressConversion)-‰PAGEš#######################################*ˆSubroutineLOGPHY %*†#A6=LOC(TCBofrequestingtask). B*†#D6.L=LOC(Buffer)tobeconverted.‚Logicaladdresscomingin;*­physicaladdressgoingout.%*†#D5.L=Numberofbytesinbuffer. LOGPHYƒEQU†*LOG_REGSREG†D0-D5/D7/A0‰MOVEM.L‚LOG_REGS,-(SP) ‰MOVE.WƒD6,CCR"‰BCS.S„L39’Startsatoddlocation. ‰MOVE.WƒD5,CCR(‰BCS.S„L39’Containsoddnumberofbytes. ‰TST.L„D5‰BEQ.S„L39’Length=0. ‰MOVE.LƒTCBTST(A6),A0‰MOVE.Lƒ#T0LOGPHY,D0 ‰TRAP…#EXEC.‰BRA.S„L40’ValidphysicaladdressnowinD6.L.‰NOP7L39†MOVEQBƒISTAADD,D0‹Badbufferaddressand/orlength. 8CMDEX2C‚BRA†CMDEXIT2Notic ethatA4andA5havenotbeen"*¦changed.‚Thevaluesofthesetwo)*¦registersareimportantinthecommand-(*¦exitroutine,andwemustneverbranch)*¦tothecommand-exitroutinewhileA4or*¦A5ismodified. '*¨Somecodeusesthebranchinstruction(*¦hereasasteppingstonetogettothe*¦command-exitroutine. L40†MOVEM.L‚(SP)+,LOG_REGS‰RTS2‰TTL†6.‚Periodically-ActivatedMeasurementRoutine-‰PAGEš#######################################-*ˆPeriodically-activatedmeasurementroutine. $*†#D0.L=Numberoftimeintervals.*†#D1.L=LOC(Channelblock).*ˆD2.L=UsedbyMEAS_RTN.*ˆD3.L=UsedbyMEAS_RTN.*ˆD4.L=UsedbyMEAS_RTN.*ˆD5.L=UsedbyMEAS_RTN.*ˆD6.L=T0QEVNTI. "*ˆA0=savedandrestoredbyexec."*ˆA1=savedandrestoredbyexec.*ˆA2=UsedbyMEAS_RTN.*ˆA3=UsedbyMEAS_RTN.*ˆA5=LOC(CCB). 8*†#SR=MaskedattheleveloftheA/Dconverterboard.  MEAS_PA‚EQU†*PA_REGS‚REG†D2-D6/A2-A3/A5‰MOVEM.L‚PA_REGS,-(SP)/‰MOVE.LƒD1,A0A0<--LOC(Masterchannelblock). /‰MOVEQ.L‚#0,D0A0-CNLBLK-CNL_NUM(A0)*CNLBLKSZ‰MOVE.BƒCNL_NUM(A0),D0‰MULU.Wƒ#CNLBLKSZ,D0‰LEA†-CNLBLK(A0),A5‰SUB.L„D0,A5A5<--LOC(CCB). ‰TST.B„ET_WAIT(A5))‰BNE.S„L60’WaitingonET.‚Skipthistime. ‰MOVEQ.L‚#T0QEVNTI,D6 ‰BSR†MEAS_RTN L60†MOVEM.L‚(SP)+,PA_REGS‰RTE‰TTL†7.‚InterruptHandler-‰PAGEš#######################################*ˆInterrupthandler !*ˆD0=SavedandrestoredbyCMR.*ˆD1=UsedbyMEAS_RD.*ˆD2=UsedbyMEAS_RD.*ˆD3=UsedbyMEAS_RD.*ˆD4=UsedbyMEAS_RD.*ˆD5=UsedbyMEAS_RD. !*ˆA0=SavedandrestoredbyCMR.!*ˆA1=SavedandrestoredbyCMR.*ˆA2=UsedbyMEAS_RD.*ˆA3=UsedbyMEAS_RD.*†#A5=LOC(CCB). B*†#SR=MaskedattheinterruptleveloftheA/Dconverterboard.  INTERUPTMOVE.LƒCCBCHB(A5),A1‰TST.B„MSBDATA(A1)ŠClearsSR.C. LˆSET†INTFF_B%‰BPL.S„L63’Notourinterrupt.‚Return. ‰TST.B„ET_WAIT(A5))‰BNE.S„L61’WaitingonET.‚Goodinterrupt. ‰ST.B…BAD_INT(A5)'‰TST.B„LSBDATA(A1)ŠClearbadinterrupt. ‰BRA.S„L62 L61†EQU†*INT_REGSREG†D1-D6/A2-A3‰MOVEM.L‚INT_REGS,-(SP)‰CLR.B„ET_WAIT(A5) 5‰MOVE.LƒCBPTR(A5),A0‰Pointertoactivechannelblock.&‰MOVE.LƒA1,A2PointertoLOC(MSBDATA).‰MOVEQ.L‚#T0QEVNTI,D6 ‰BSR†MEAS_RD ‰MOVEM.L‚(SP)+,INT_REGS L62†EQU†*CARRY„EQU†1<<0‰OR.B…#CARRY,CCRL63†RTS NNNœ ?‰TTL†MVME-600andMVME-601Analog-to-DigitalI/ODriverProgramN  NNNNNN?'-/(7*?(G#O.W3_3g6o:w::‡9 —$Ÿ$§7¯6·)¿3Ç8Ï6×;ß5ç<ï:÷9ÿ6  /*ƒVV‡VVƒMM‡MMƒEEEEEEEEE„6666666…0000000…00000007*ƒVV‡VVƒMMM…MMMƒEEEEEEEEEƒ666666666ƒ000000000ƒ000000000(*„VV…VV„MMMMƒMMMMƒEEŠ66…66ƒ00„/00ƒ00„/00)*„VV…VV„MMMMMMMMƒEEŠ66Š00ƒ//00ƒ00ƒ//005*…VVƒVV…MM‚MMM‚MMƒEEEEEEEE„66666666„00‚//00ƒ00‚//004*…VVƒVV…MMƒMƒMMƒEEEEEEEE„666666666ƒ00//‚00ƒ00//‚00&*†VVVV†MM‡MMƒEEŠ66…66ƒ00//ƒ00ƒ00//ƒ00$*†VVVV†MM‡MMƒEEŠ66…66ƒ00/„00ƒ00/„003*‡VVV‡MM‡MMƒEEEEEEEEEƒ666666666ƒ000000000ƒ000000000+*ˆVˆMM‡MMƒEEEEEEEEE„6666666…0000000…0000000   *—AAAAAŽ//ƒDDDDDDDDD*–AAAAAAAŒ//„DDDDDDDDDD*•AA…AAŠ//†DD…DD*•AA…AA‰//‡DD…DD*•AAAAAAAAAˆ//ˆDD…DD*•AAAAAAAAA‡//‰DD…DD*•AA…AA†//ŠDD…DD*•AA…AA…//‹DD…DD*•AA…AA„//‹DDDDDDDDDD*•AA…AAƒ//ŒDDDDDDDDD   4*…DDDDDDDDD„RRRRRRRR„IIIIIIƒVV‡VVƒEEEEEEEEEƒRRRRRRRR7*…DDDDDDDDDDƒRRRRRRRRRƒIIIIIIƒVV‡VVƒEEEEEEEEEƒRRRRRRRRR*†DD…DDƒRR…RR…II†VV…VV„EEŠRR…RR*†DD…DDƒRR…RR…II†VV…VV„EEŠRR…RR-*†DD…DDƒRRRRRRRRR…II‡VVƒVV…EEEEEEEE„RRRRRRRRR+*†DD…DDƒRRRRRRRR†II‡VVƒVV…EEEEEEEE„RRRRRRRR*†DD…DDƒRR‚RRˆIIˆVVVV†EEŠRR‚RR*†DD…DDƒRRƒRR‡IIˆVVVV†EEŠRRƒRR-*…DDDDDDDDDDƒRR„RR„IIIIII‡VVV‡EEEEEEEEEƒRR„RR**…DDDDDDDDD„RR…RRƒIIIIIIˆVˆEEEEEEEEEƒRR…RR        E*ˆThisprogramisre-entrantandpositionindependent,‚anditcanrunF*ƒinaROMthat‚appears‚at‚anyconvenient‚location‚inthe68000memoryB*ƒspace.„Asingle‚copyofthe‚A/D‚drivercan‚controlany‚number‚of@*ƒMVME-600andMVME-601A/Dmeasurementchannelssimultaneously.‰TTL‡TableofContents‰PAGE*ŸTableofContents*I*‚1.‚Introduction...........................„4*I*‚2.‚Options,Macros,Equates,andDataStructures‚..........ƒ10*E*†2.1.‚MiscellaneousOptionsandEquates‚.............ƒ11E*†2.2.‚MacroDefinitions‚.....................ƒ15E*†2.3.‚CMRParameterBlock‚....................ƒ22F*†2.4.‚IOCB(I/OCommandBlock)Structure.............ƒ27*?*Œ2.4.1.‚IOCBOFFSETBlock‚.................ƒ28?*Œ2.4.2.‚CMD_CODE(Command-Code)Equates‚..........ƒ38@*Œ2.4.3.‚STATUSEquates...................ƒ39*E*†2.5.‚CCB(ChannelControlBlock)Structure‚....  .......ƒ46*@*Œ2.5.1.‚Universally-DefinedCCBFields...........ƒ47?*Œ2.5.2.‚CCBFieldsfortheA/DDriver‚...........ƒ53*0*”2.5.2.1.‚A/DCCBFieldsRelatingtoaComplete/*žMVME-600A/DConverterBoard.......ƒ543*”2.5.2.2.‚CCBChannelBlockforanA/DMeasurement.*žChannel‚.................ƒ60*F*†2.6.‚TCB(TaskControlBlock)Structure.............ƒ74E*†2.7.‚I/OEventStructure‚....................ƒ75E*†2.8.‚MVME-600andMVME-601MemoryLayout‚............ƒ79*?*Œ2.8.1.‚Memory-MappedI/OSpace‚..............ƒ79@*Œ2.8.2.‚ControlRegister..................ƒ82?*Œ2.8.3.‚OutputDataRegisters‚...............ƒ85@*Œ2.8.4.‚Channel-NumberEquates...............ƒ87*J*‚3.‚RequiredDriverTables......................ƒ90*F*†3.1.‚A/DServiceVectorTable..................ƒ91F*†3.2.‚ParameterTableforCMRParameters.............ƒ93F*†3.3.‚RevisionTable.......................ƒ94*I*‚4.‚InitializationSection(SubroutineINITIAL)‚...........ƒ95* *Â(Continued)*‰PAGE*™TableofContents,Continued*J*‚5.‚CommandServiceSection‚.....................‚101*F*†5.1.‚CommandSwitchingTable‚..................‚102F*†5.2.‚SubroutineCOMMANDS(CommandProcessor)‚..........‚104*@*Œ5.2.1.‚OPEN_CMDRoutine(OPENCommand)‚..........‚111@*Œ5.2.2.‚CommonExitRoutine‚................‚xxx@*Œ5.2.3.‚STOP_CMDRoutine(STOPCommand)‚..........‚xxxA*Œ5.2.4.‚CLOSECMDRoutine(CLOSECommand)..........‚xxx@*Œ5.2.5.‚MEAS_DandMEAS_SRoutines(MEASURECommands)‚...‚xxx*9*”5.2.5.1.‚InitialDecodingofHeaderSection....‚xxx8*”5.2.5.2.‚FirstPassthroughtheChannelBlocks‚..‚xxx9*”5.2.5.3.‚SecondPassthroughtheChannelBlocks..‚xxx9*”5.2.5.4.‚FinalCommandSet-Up...........‚xxx9*”5.2.5.5.‚MEAS_RTN(MeasurementRoutine)......‚xxx8*”5.2.5.6.‚SubroutineWAKEUP‚............‚xxx8*”5.2.5.7.‚SubroutineQEVENT‚............‚xxx*A*Œ5.2.6.‚CommonSubroutines.................‚xxx*8*”5.2.6.1.‚SubroutineSTOP‚.............‚xxx8*”5.2.6.2.‚SubroutineVALIDATE‚...........‚xxx8*”5.2.6.3.‚SubroutineVALID_CN‚...........‚xxx1*”5.2.6.4.‚SubroutineLOGPHY(Logical-to-Physical/*žAddressConversion)‚...........‚xxx*K*‚6.‚Periodically-ActivatedMeasurementRoutine............‚xxx*J*‚7.‚InterruptHandler‚........................‚xxx*K*‚8.‚Symbol-TableConcordance.....................‚xxx‰TTL‡1.‚Introduction‰PAGE*Ÿ1.‚Introduction*H*‡Thisprogram,whichiscommonlyknownastheA/Ddriver,istheRMS68KG*‚I/O‚driver‚for‚the‚MVME-600‚analog-to-digital‚converterboardandtheK*‚MVME-601analog-to-digitalexpanderboard.‚RMS68Kisthepopularname‚forI*‚the‚Real-Time‚Multitasking‚Software‚thatformsthekernelofMotorola'sL*‚real-timeoperatingsystemforprocessorsinthe68000family,andthe‚A/DI*‚driver‚runs‚in‚supervisor‚modeasanextensionoftheRMS68Kexecutive.F*‚TheA/Ddriver‚provides‚the‚device-dependent‚portion‚of‚the‚softwareG*‚interface‚for‚any‚desired‚number‚of‚MVME-600A/Dconverterboardsand*‚MVME-601A/Dexpanderboards.*G*‡TheA/Ddriveriswrittenasare-entrantprogram,andtheprogram‚isL*‚alsowrittentobepositionindependent.‚Therefore,theobjectprogramforJ*‚theA/DdrivercanbeexecutedfromaROMthatappears‚at‚any‚convenientF*‚location‚in‚the‚68000‚address‚space,‚and‚theprogramcanbeexecutedM*‚re-entrantlysothatasinglecopyoftheA/DdrivercancontrolanynumberC*‚ofMVME-600andMVME-601A/Dmeasurementchannelssimultaneously.*E*‡Besides‚readingany‚furthe  r,‚thereadershouldcarefullyreviewthe)*‚hardwareuser'smanualfor‚the‚MVME-600F*‚A/D‚converter‚board‚and‚the‚MVME-601‚A/Dexpanderboard.‚ThatmanualG*‚describesbothboardsin‚detail,‚and‚it‚provides‚complete‚informationJ*‚regarding‚the‚jumpers‚andotherhardwareoptionsthatareavailablewithF*‚theboards.‚Thehardwaremanualfor‚the‚MVME-600‚and‚the‚MVME-601‚is*‚availableasfollows:*‰PAGEG*‚MVME600AnalogInputModuleMVME601A/DExpanderModuleUser'sManual(*‚ManualNumber:‚MICROSYSTEMSMVME600/D1*'*‚MotorolaSemiconductorProducts,Inc.*‚LiteratureDistribution*‚P.O.Box20912*‚Phoenix,Arizona‚85036*‚(602)994-6561**‰PAGEG*‡Thedriverislargelytabledriven,andmanyfuturemodifications‚canF*‚be‚made‚by‚simply‚changing‚table‚entries‚orbyaddingnewentriesto*‚existingtables.*B*‡Thesubroutinesinthe‚A/D‚driver‚are‚general-purpose‚in‚nature.J*‚Instead‚of‚being‚usedtothelimitsoftheircapabilitiesinthepresentG*‚versionofthedriver,they‚are‚flexible‚enough‚to‚perform‚additionalL*‚functionsthatmaybeneededinthefuture.‚SomesubroutinesmaybecalledI*‚fromonlyoneplace,buttheyarestillcoded‚as‚subroutines‚to‚provideL*‚modularity‚oforganizationandtomaketheirfunctionseasilyavailableto!*‚futuremaintenanceprogrammers.*A*‡Insteadofusing‚a‚complicated‚and‚error-prone‚method‚of‚makingJ*‚measurements‚under‚interrupt‚control,theA/DdriverusesasimplesenseD*‚looptomake‚normal‚measurements.ƒA‚measurement‚that‚is‚made‚underJ*‚sense-loop‚control‚requires‚only38microsecondsofsense-loopoverhead,H*‚andtheoverheadthatisrequiredto‚service‚a‚single‚interrupt‚easilyH*‚exceeds‚38‚microseconds.ƒTherefore,‚thedriveractuallysavestimeandF*‚improvesthroughputbyusinga‚simple‚sense‚loop‚instead‚of‚using‚anJ*‚interrupt-driven‚scheme‚formakingmeasurements.‚TheA/Ddriverdoes,ofI*‚course,useaninterrupt-drivenschemewhenthedriver‚wants‚to‚make‚an#*‚externally-triggeredmeasurement.*E*‡To‚promote‚readability‚andmaintainability,thefollowingstandards3*‚arecarefullyobservedthroughouttheA/Ddriver.*=*ŒAllinstructionsintheA/Ddriveraretypedinupper‚case,>*‡and‚comments‚are‚always‚typed‚inamixtureofuppercaseand%*‡lowercasetomaximizereadability.*<*ŒTabstopsintheA/Ddriverareincolumns10,19,‚40,‚and=*‡42,‚and‚the‚right-hand‚margin‚isincolumn78.‚Thesametab;*‡stops‚and‚the‚same‚right-hand‚margin‚are‚used‚religiously<*‡throughout‚the‚driver‚to‚ensure‚consistent‚formatting.‚The?*‡opcodefieldstartsatthetabstopin‚column‚10,‚the‚operand*‰PAGEB*‡field‚startsatthetabstopincolumn19,andthecommentfield=*‡startsatthetabstopincolumn40.‚We‚use‚the‚tab‚stop‚in:*‡column‚42‚to‚provide‚indentation‚for‚the‚first‚line‚ofaA*‡paragraphofcodecomments.‚Pleaserefertoanysectionof‚codeA*‡anywhere‚in‚theentireprogramlistingtoseehowcodecomments*‡areformatted.*<*ŒInstructionsthroughouttheA/Ddriverare‚carefully‚coded:*‡to‚prevent‚the‚operand‚field‚of‚an‚instruction‚from‚ever>*‡extendingintothecommentfield,‚which‚begins‚in‚column‚40.A*‡Where‚necessary,‚wedefinelabelsofalocalnaturetoallowusA*‡toshortenalongoperandfieldandtherebyprevent‚the‚operandA*‡field‚fromextendingintothecommentfield.‚Bymaintainingthe?*‡strictcolumnizationof‚non-overlapping‚fields‚throughout‚theA*‡entire‚program,‚wesignificantlyimprovethereadabilityofthe *‡listing.*;*ŒThecurrentversionofMotorola's‚68000‚assembler‚doesn'tC*‡supportlocallabels,soweuselabelsoftheformLj,Ljj,Ljjj,;*‡orLjjjjwhere‚local‚labels‚would‚ordinarily‚be‚used.ƒFor=*‡example,‚a‚label‚such‚as‚L1,‚L12,L123,orL1234intheA/D=*‡driverisalwaysalocallabelwithnoglobalsignificance.*6*ŒWeusethelabel"L"‚in‚a‚rather‚special‚way.ƒWhen‚aC*‡segmentofcodeusesanaddressingmodesuchasregister-indirect>*‡addressingtoaccessa‚variable‚without‚explicitly‚using‚t  heB*‡variable's‚label,weplaceaSETassemblerdirectiveimmediately:*‡afterthe‚code‚segment‚to‚set‚L‚temporarily‚equal‚to‚the?*‡variable's‚label.ƒWe‚don'treallycareaboutthevalueofthe?*‡labelL,butwedocareaboutthefact‚that‚the‚SET‚assemblerC*‡directivegeneratesaconcordanceentryforthevariable'slabel.A*‡Futuremaintenanceprogrammerswillconvenientlybeable‚to‚useC*‡theconcordancelistingtofindreferencestovariablesevenwhen6*‡thevariablenamesaren'tuseddirectlyinthecode.*E*‡Someofthelabelsthatareusedinthevarious‚I/O‚data‚structuresK*‚are‚non-mnemonic,‚andafewofthelabelsinthedatastructuresareevenL*‚anti-mnemonic.‚TheselabelshavebeencreatedbyanumberofpeopleastheH*‚operating‚system‚has‚grown‚over‚theyears,andtheselabelsarenowsoG*‚firmlyentrenchedthattheycan't‚reasonably‚be‚changed.ƒAlthough‚theK*‚labels‚in‚theI/Odatastructurescan'teasilybechanged,theA/DdriverL*‚doesatleastprovidecommentstoexplainthetruemeaningsofthe‚variousG*‚fieldsoftheI/OdatastructuresastheyareusedbytheA/Ddriver.*5‰TTL‡2.‚Options,Macros,Equates,andDataStructures‰PAGE2*2.‚Options,Macros,Equates,andDataStructures*B*‡Before‚we‚get‚into‚the‚actual‚codeoftheA/Ddriver,weneedtoI*‚defineafewmiscellaneousmacrosandsomeequatesthat‚are‚used‚by‚the *‚driver.*F*‡We‚also‚needtodefinethedatastructureswithwhichtheA/DdriverL*‚works.‚ThesedatastructuresincludetheIOCB(I/OControlBlock),theCMRI*‚parameter‚block,‚the‚CCB‚(ChannelControlBlock),theTCB(TaskControlI*‚Block),theI/Omeasurementeventmessage,and‚the‚I/O‚completion‚eventJ*‚message.ƒThe‚A/DdriversharesthesedatastructureswithotherpartsofI*‚thesystemsoftware,andtheA/Ddriverdoesn'tuse‚every‚part‚of‚everyJ*‚data‚structure.ƒThedocumentationinthissectionexplainsprimarilytheF*‚partsofthedatastructuresthataresignificanttotheA/Ddriver.*E*‡Besidesusingthedatastructuresthatarementioned‚above,‚the‚A/DH*‚driver‚also‚deals‚with‚the‚memory-mappedI/OareafortheMVME-600A/DH*‚converterboardanditssubordinateMVME-601‚A/D‚expander‚boards.ƒThisH*‚section‚of‚the‚listing‚includes‚adefinitionofthatmemory-mappedI/O*‚area.+‰TTL‡2.1.‚MiscellaneousOptionsandEquates*‰PAGE(*”2.1.‚MiscellaneousOptionsandEquates*D*‡This‚section‚contains‚some‚optionsthattelltheassemblerwhatweM*‚wantittodo,andthissectionalsocontainssomemiscellaneousequatestoK*‚define‚labelsthatareusefulforthecodeintheA/Ddriver.‚TheequatesL*‚inthissectionarepresentedinalphabeticalorderforeaseof‚reference.E*‚The‚options‚must‚occur‚before‚any‚code-affecting‚or‚code-generatingL*‚statementsbecausetheoptionstelltheassemblerhowtoassemblethe‚rest*‚oftheprogram.  1‰NOFORMAT–####################################### ‰OPT†CRE,PCS /CODE…EQU†8–Thislabeldefinesthenumberof‚the(*¦program‚sectionthatcontainscodeand&*¦constants.‚Section8is‚a‚relatively"*¦arbitraryƒsection,ƒbut‚it‚is‚the&*¦sectionwherethe‚system‚expects‚(by%*¦default)toseecodeforaprogram. ?DELAY„EQU†38microsecondsˆThislabeldefinestheamountoftime$*¦(in‚terms‚of‚microseconds)‚that‚is(*¦required‚foranMVME-600A/Dconverter)*¦boardtocompleteasingleA/Dmeasure-&*¦ment.ƒThe‚A/Ddriverusesthislabel(*¦whenthedriverdelaystowaitfor‚the"*¦boardƒto‚make‚a‚measurement.ƒThe'*¦drivertimeseachA/D‚measurement‚and'*¦aborts‚with‚anerroriftheA/Dboard)*¦doesn'tcompleteameasurementwithina*¦reasonableamountoftime.-‰PAGEš#######################################)EXEC…EQU†0–This‚label‚is‚used‚with‚aƒTRAP%*¦instruction‚to‚generate‚a‚trapthat *¦requestsanexecutiveservice. 8INT_MASKEQU†$0700’Thislabeldefinesabitmaskforthe#*¦interrupt-levelƒbitsƒin‚the‚68000&*¦statusregister.‚TheA/D‚driver‚us  es'*¦this‚label‚whenthedriverdealswith*¦theinterrupt-levelbits. :MAXCNLS‚EQU†(1+5)*16Thislabeldefinesthemaximumnumber(*¦of‚measurementchannelsthatcanexist%*¦inasingleCMRA/D‚channel.ƒAn‚A/D'*¦channel‚must‚containoneMVME-600A/D(*¦converterboard,anditcan‚optionally%*¦contain‚as‚many‚as‚fivesubordinate(*¦MVME-601A/Dexpanderboards.‚Themain)*¦A/Dconverterboardcontains16single-&*¦endedmeasurement‚channels,‚and‚each$*¦expanderƒboard‚contributes‚16‚more$*¦single-endedmeasurementchannels. ;‰IFNE…MAXCNLS/4*4-MAXCNLS„TheA/D‚driver‚contains‚code‚that-‰FAILš[****ERROR****ERROR****ERROR****]-‰ENDCšworksundertheassumptionthatMAXCNLS&*¦is‚evenly‚divisibleby4.‚Ifsomeone$*¦ever‚changes‚something‚thatƒcauses'*¦MAXCNLS‚not‚tobeevenlydivisibleby(*¦4,thestatementthatis‚conditionally(*¦skipped‚herewillgenerateanassembly&*¦errortoalertthe‚programmer‚to‚the$*¦failure.ƒBy‚using‚the‚assemblerto'*¦performthischeck,wecanbe‚sure‚of$*¦finding‚the‚error‚at‚assembly‚time)*¦insteadoffindingitlaterasaresult#*¦ofadifficultdebuggingsession.-‰PAGEš#######################################0MHZ†EQU†100”Thislabeldefinesthemaximum‚clock&*¦rate‚(in‚terms‚ofmegahertz)thatis(*¦expectedfora68000microprocessor‚in&*¦the‚near‚future.‚TheA/Ddriveruses)*¦thislabelwhenittimesameasurement,&*¦and‚we‚want‚MHZtobehighenoughto(*¦insureanadequatetimedelaywith‚the'*¦fastest‚foreseeable68000.‚Ifweever&*¦startgetting68000‚systems‚that‚can(*¦run‚withclockspeedsinexcessof100(*¦megahertz,wemustadjustthevalue‚of'*¦this‚labelupward.‚Ontheotherhand,)*¦avalueforMHZthatislargerthanthe"*¦actualƒspeedƒof‚the‚system‚clock(*¦doesn'tpresentanyproblems.‚Alarger%*¦MHZ‚value‚simply‚means‚thattheA/D(*¦driverdelayslongerinaSTOP‚command'*¦and‚before‚itabortsameasurementin)*¦thecaseofanA/Dconverterboardthat%*¦has‚gone‚bad.ƒSincetheextradelay&*¦occursonlyin‚conjunction‚with‚STOP)*¦commandsandwithboardfailures,itis)*¦notlikelytobeanoticeablefactorin*¦actualpractice. /SAFETYƒEQU†2–This‚label‚defines‚asafetyfactor(*¦thattheA/Ddriveruseswhenit‚times&*¦out‚a‚measurement.‚Bydelayingtwice%*¦aslongas‚should‚be‚necessary,‚the(*¦A/D‚driverprovidesanextramarginof'*¦safetythatwillforestall‚the‚advent'*¦of‚timing‚errorsuntiltimingchanges(*¦exceedthelimitofthesafetyfactor.-‰PAGEš#######################################4T0LOGPHYEQU†8–Theselabelsdefineexecutive-request7T0QEVNTIEQU†24“codesthatareusedwhentheA/Ddriver7T0QEVNTTEQU†23“makesexecutiverequestsviaTRAP#EXEC3T0RQPAƒEQU†34“callstotheexecutive.‚The‚executive6T0WAKEUPEQU†22“requests‚andtheirfunctionsarefully#*¦documented‚in‚theƒstandardƒRMS68K%*¦documentation‚package.ƒBriefly,‚the)*¦functionsoftheseparticularexecutive*¦requestsareasfollows: $*¨T0LOGPHY‚converts‚a‚logicalmemory)*¦addressintoaphysicalmemoryaddress.)*¦Addressconversionisnecessarybecause(*¦tasksuselogicalmemory-mapped‚memory(*¦addresses‚whereastheA/Ddriver,like(*¦therestoftheoperatingsystem,‚uses#*¦actualphysicalmemoryaddresses. '*¨T0QEVNTIqueuesaneventmessagefrom(*¦aninterrupthandlertoatask.‚Please$*¦noteƒthatƒa‚periodically-activated#*¦routine‚such‚asƒtheƒperiodically-&*¦activated‚A/D‚measurement‚routineis(*¦consideredtobeaninterrupthandler. '*¨T0QEVNTTqueuesaneventmessagefrom'*¦a‚task-level‚process(suchastheA/D)*¦driver'scommand-processingsubroutine)"*¦toƒa‚task.ƒThe‚driver's‚command-(*¦processingsubroutineisconsidered‚to'*¦be‚a‚task-levelprocessbecauseitis$*¦invokeddirectly‚as‚a‚result‚of‚an'*¦executive‚request‚fromataskinstead#*¦ofbeinginvokedbyaninterrupt. '*¨T0RQPArequestsaperiodicactivation'*¦of‚a‚specifiedroutineataspecified'*¦interruptlevel.‚TheT0RQPA‚executive(*¦requ  est‚canalsobeusedtodeactivate$*¦a‚routine‚that‚has‚previously‚been$*¦activated.ƒThe‚A/D‚driver‚usesthe&*¦T0RQPAexecutive‚request‚to‚activate"*¦and„deactivateƒtheƒperiodically-$*¦activatedA/Dmeasurementroutine. %*¨T0WAKEUPwakesupa‚specified‚task."*¦TheƒA/Dƒdriver‚uses‚the‚T0WAKEUP%*¦executiverequestto‚wake‚up‚a‚user'*¦task‚when‚theusertaskhasaskedthe(*¦drivertowakeitupatthe‚completion)*¦ofsomemeasurementorsomesequenceof*¦measurements.‰TTL‡2.2.‚MacroDefinitions‰PAGE*œ2.2.‚MacroDefinitions*G*‡This‚sectioncontainsthedefinitionsofseveralmacrosthatmightbeL*‚usefulintheA/Ddriver.‚Foreaseofreferencethemacrosinthissection&*‚arepresentedinalphabeticalorder.*C*‡Macros‚are‚occasionally‚useful‚for‚modifyingsomeofthebuilt-in#*‚characteristicsoftheassembler.-‰PAGEš#######################################0ADDIA„MACRO›This‚macroisusefulwhenwewantto#*¦add‚an‚immediate‚value‚to‚an‚"*¦register.„Ifƒthe‚immediate‚value#*¦happensto‚be‚in‚the‚range‚from‚1(*¦through‚8,thismacrogeneratesaone-!*¦word‚ADDQ.Lƒinstruction.„Ifƒthe(*¦immediate‚valueisoutofrangeforan(*¦ADDQ.Linstructionbutissmall‚enough)*¦toberepresentedcorrectlyina16-bit&*¦two's-complement‚number‚system,‚this"*¦macroƒgeneratesƒaƒtwo-word‚ADD.W)*¦instructionknowingthatsignextension)*¦willoccuratexecutiontimetoaddthe)*¦correct32-bitvaluetotheentire(*¦register.‚Otherwise,thismacrogener-&*¦atesathree-wordADD.Linstruction. '*¨Byusingthismacrowecanbeassured$*¦ofƒgenerating‚the‚shortest‚correct'*¦instruction,andthemacro‚will‚still%*¦function‚correctly‚if‚the‚immediate(*¦valuehappenstochangeasaresult‚of#*¦futureƒprogramƒmodifications.ƒThe$*¦ADDIAmacroisinvokedasfollows. !*¦[