	.TITLE VW
/ 
/ 
/                   FIRST PRINTING, FEBRUARY 1974
/ 
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
/ CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
/ AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
/ SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
/ DOCUMENT.
/ 
/ THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
/ NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
/ A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
/ INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
/ USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
/ VIDED IN WRITING BY DIGITAL.
/ 
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/ FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
/ MENT THAT IS NOT SUPPLIED BY DIGITAL.
/ 
/ COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/
/ EDIT #04	7/16/73		S. ROOT
/	UPDATE COPYRIGHT

/

/ PROGRAM CODE UNKNOWN

/

/ COPYRIGHT 1972, DIGITAL EQUIPMENT CORP., MAYNARD, MASS., 01754

/

/	WRITING TABLET HANDLER UNDER RSX-PLUS

/
/	WILL HANDLE A MAXIMUM OF FOUR TABLETS

/

	.DBREL

/	RSX EQUALITIES

/

R1=101

R2=102

R3=103

R4=104

POOL=240

PDVL=252

NADD=107

ALAD=325

DLAD=332
DQRQ=337		/GET REQUEST NODE UNLESS DEVICE ATTACH'ED
/			/TO A DIFFERENT USER
IOCD=345

VJAX=342
PICK=120		/GET REQUEST NODE IRREGARDLESS

DMTQ=361

.INH=705522

.ENB=705521
VWINFO=23		/CODE FOR DEVICE. NO INPUT,OUTPUT,DIRECT.
/
/  EQUATES TO USE INITIALIZATION CODE FOR TABLES

/

ST0=VWA

ST1=ST0+1

ST2=ST0+2

ST3=ST0+3

RQ0=VWA+4

RQ1=RQ0+1

RQ2=RQ0+2

RQ3=RQ0+3

POST0=VWA+10

POST1=POST0+1

POST2=POST0+2

POST3=POST0+3

X0=VWA+14

X1=X0+1

X2=X0+2

X3=X0+3

Y0=VWA+20

Y1=Y0+1

Y2=Y0+2

Y3=Y0+3
RWNOD=VWA+24		/OUTSTANDING REQUEST NODE ADDR
/			/FOR EACH OF FOUR UNITS. ZEROED WHEN REQ.
/			/COMPLETED, SO IT IS ALSO A SWITCH.
RTRN0=VWA+30		/BUFFER INTO WHICH DATA TO BE RETURNED
/			/IDENTIFIES PARTITION ISSUING LAST GET TO
/			/UNIT. ALSO A FLAG, BEING ON (NON0) ONLY
/			/WHEN MOD FOR SAME UNIT NON0.
MOD0=VWA+34		/MODE OF OPERATION FOR THIS TABLET
/			/CONT. DATA 100010, PEN DATA 100, 
/			/NOT BEING USED 0.
MOD1=MOD0+1		/CONT. DATA 100004, PEN 100, NONE 0
MOD2=MOD0+2		/CONT. 100002, PEN 100, NONE 0
MOD3=MOD0+3		/CONT. 100001, PEN 100, NONE 0
IOCDW=VWA+40		/POINTER TO I/O COUNTDOWN WD IN PARTITION
/			/BLOCK.WE KICK XTRA TIME (IF NOT EXEC MODE)
/			/TO INSURE WE GET CONTROL AT ABORT TIME
/			/TO TURN OFF THE SILLY SPARKS IF NECESSARY.
ZOT=VWA+44		/FOUR TEMPORARIES

ZOT1=ZOT+1
ZOT2=ZOT+2
ZOT3=ZOT+3
IOCADD=VWA+50		/HOLD PARTITION ADDR HERE.

/

/

/  INITIALIZATION CODE

/
VWA	LAC	IVW	/ADDRESS OF EVENT VARIABLE TO FIND PAGE
	AND	I70000	/ONLY THESE BITS CAN BE PAGE BITS

	CMA!IAC

	DAC	NEGPAG	/SAVE NEGATIVE OF PRESENT PAGE LOC.

	LAC*	IPDVL	/GET FIRST NODE ADDR

VWL	PAL		/SAVE UNCORRECTED NODE ADDR

	TAD	NEGPAG	/CORRECT PAGE SO CAN INDEX

	PAX		/FOR 2,X TYPE ADDRESSING

	LAC	2,X	/GET DEVICE NAME

	SAD	VWSXBT	/IS IT A VW@@@@?

	JMP	VWFND	/GOT ONE!

NOPE	LAC	0,X	/GET POINTER TO NEXT NODE

	SAD	IPDVL	/IF FIRST ONE, WE'RE DONE

	JMP	SCNFIN	/YES, SCAN FOR DEVICES FINISHED

	JMP	VWL	/STILL MORE NODES, BACK TO LOOP

/

I70000	70000		/LITERAL FOR INIT. CODE ONLY
IPDVL	PDVL		/LIKEWISE
IVW	VWEV		/ADDR OF OUR EVENT VARIABLE
VWSXBT	.SIXBT	"VW@"	/VW IN SIXBIT FOR UNIT FIND LOOP
/
/	SAVE VW NODES IN TABLE ORDERED BY UNIT #

/

VWFND	LAC	5,X	/GET UNIT NUMBER
	TAD	(VWTAB	/TABLEADDRESS
	DAC	UNITXR	/A TEMPORARY

	PLA		/BRING BACK CORRECT NODE ADDR.
	DAC*	UNITXR	/AND PLACE REAL ADDR IN TABLE
	LAC	IVW	/ADDR OF HANDLER EV. (USED FOR BOTH

/			/USER LEVEL TO OUR LEVEL,

/			/AND INTERRUPT LEVEL BACK TO OUR LEVEL.

	DAC	10,X	/PUT INTO PHYSICAL TABLE, SO WE

/			/CAN BE CALLED WHEN A REQUEST HAPPENS

	JMP	NOPE	/REJOIN SCAN FOR NODES LOOP

/

/  SCAN FOR PHYSICAL DEVICES DONE

/
SCNFIN	LAC	UNITXR	/DID WE FIND ANY

	SNA		/SKIP IF YES

	CAL	(10	/EXIT IF WE DIDNT

	CAL	VWCON	/GOT SOME, CONNECT TO API

	LAC	VWEV	/DID IT HAPPENALL RIGHT?

	SPA!CLA		/SKIP IF YES.

	CAL	(10	/NO, JUST EXIT
	CLX		/SET UP LOOP TO CLEAR INIT. CODE
	AAC	WAIT-VWA-4  /FOR USE IN TABLES

	PAL

	DZM	VWA,X	/DZM LAST LOC NOT CLEARED

	AXS	1	/LOOP DONE
	JMP	.-2	/NOPE
	JMS	HOW	/CLEAR TABLETS (MOD0-MOD3 ALL 0)

/

/  WAIT HERE FOR ANY ACTION FROM USER OR INTERRUPT

/

WAIT	CAL	VWAIT	/WAIT ON VWEV

	.INH		/THIS MAY BE HISTORICAL ARTIFACT (DP....)

	LAC	VWEV	/MUST CHECK IF ABORT REQUEST

	AND	(100000	/LEAVE ONLY I/O RUNDOWN BIT

	SZA		/SKIP ON REGULAR REQUEST

	JMP	ABORT	/GO CLEAN UP AFTER USER

	.ENB		/ALLOW INTERRUPTS AGAIN

WAITR	DZM	VWEV	/CLEAR EVENT VARIABLE

	DZM	UNITXR	/SCAN TABLE BY UNIT # FOR ACTION

	SKP		/MISS ISZ AT LOOP TOP

VWNXT	ISZ	UNITXR	/MOVE TO NEXT UNIT NUMBER

	LAC	UNITXR	/TO PLACE IN INDEX REG TO ACCESS TABLES

	PAX		/IN PLACE

	LAC	VWTAB,X	/GET NODE ADDR FOR THIS UNIT NUMBER

	SPA		/SKIP ON REAL OR EMPTY NODE

	JMP	LEAVE	/MINUS END OF TABLE STOPPER

/			/CHECK ASSIGN INHIBIT FLAGS....

	SNA		/SKIP ON REAL NODE

	JMP	VWNXT	/ZERO SHOWS NO DEVICE, KEEP SCANNING

	DAC*	(R1	/REAL NODE ADDR IN SYS REG. IN CASE WE

/			/HAVE TO DEQUE THE REQUEST NODE

	LAC	POST0,X	/ARE WE WAITING FOR INTERRUPT FOR THIS UNIT

	SZA		/SKIP IF WE ARE NOT

	JMP	BAKDWN	/WE ARE, GO DO FURTHER CHECKING

	JMS*	(DQRQ	/DEQUE REQUEST NODE FOR A USER REQUEST

/			/SINCE THIS UNIT IS NOT PRESENTLY BUSY.

	JMP	VWNXT	/WASN'T ONE,!?!?!?, GO ON FOR NEXT NODE

	DAC	ZOT	/SAVE NODE ADDR, WHILE WE RELOAD UNITXR

	LAC	UNITXR	/SINCE DQRQ ZAPPED XR

	PAX

	LAC	ZOT	/AND HERE IS THE NODE ADDR FOR REQ.

	DAC	RWNOD,X	/INTO REQUEST TABLE BY UNIT #

	AAC	4	/USE AUTO-INCR TO GET NODE+5,NODE+7
	DAC*	(10	/10 ARBITRRY
	AAC	-1	/MOVE POINTER BACK TO NODE+3
	DAC	ZOT3	/SUPER TEMPORARY FOR ADDRESSING
	LAC*	ZOT3	/PARTITION BLCOK ADDR IF USER MODE (0 EXEC MODE)
	SZA		/SKIP ON EXEC MODE
	AAC	7	/ADDR OF I/O COUNTDOWN WD. IN PARTITION BLK.
	DAC	IOCADD	/USE THIS LOC. TO HOLD IT FOR LATER
	LAC*	10	/GET CAL CODE FROM NODE+5

	AND	(777	/STRIP UNUSEFUL HIGH BITS

	SAD	(24	/ATTACH CODE

	JMP	ATTACH	/YES

	SAD	(25	/DETACH?

	JMP	ATTACH	/COMMON CODE WITH ATTACH

	SAD	(36	/HINF

	JMP	HINF

	SAD	(777	/DISCONNECT AND EXIT REQUEST

	JMP	ELEX	/ALTERNATE PATH FROM CHECK OF

/			/REASSIGN INHIBIT FLAG
	SAD	(30	/IS IT A GET
	JMP	GET	/YES
	SAD	(34	/IS IT A CLOSE
	JMP	CLOSE	/YUP
VWUNIM	LAW	-6	/ALL OTHERS ARE ILLEGAL

	JMP	ERRREQ	/ERROR, CODE IN AC TO CALLER

FINREQ	CLA!IAC		/OK, GIVE BACK A 1 TO EVENT VARIABLE

ERRREQ	DAC	GIVEEV	/PLACE CODE IN ARG. FOR

/			/ROUTINE GIVE

	LAC	UNITXR	/GET BACK UNIT # TO XR

	PAX

	LAC	RWNOD,X	/REQUEST NODE FOR THIS UNIT
	DZM	RWNOD,X	/SHOW WE ARE DONE WITH NODE.
	JMS	GIVE	/ROUTINE TO DO IOCD, DECLARE EVENT
/			/AND RETURN THE NODE TO THE POOL
	JMP	VWNXT	/GO LOOK FOR MORE WORK

/

/

BAKDWN	SAD	RQ0,X	/IF SAME, NO INTERRUPT YET

	JMP	VWNXT	/SO PRESENT REQ.MUST WAIT FOR PREVIOUS

/			/TO FINISH.

	DZM	POST0,X	/IF DIFFERENT, THIS IS INTERRUPT LEVEL

/			/COMING BACK TO US TO FINISH REQ.

	LAC	RTRN0,X	/GET POINTER (-1) TO USER BUFFER
	DAC*	(10	/USE AUTONCREMENT REG.
	LAC	ST0,X	/GET STATUS
	CLL!RAR		/MUST GIVE BACK TO USER 0 IF PEN DATA
/			/+ IF CONT. DATA , - IF CONT DATA MULTIPLEX
	RTR		/PUT MULTIPLEX BIT INTO LINK
	AND	(20040	/MASK FOR PEN DATA, SINGLE POINT. AC NON0 FOR PEN
	SNA!CLA		/SKIP PEN DATA, SETTING AC=0 FOR PEN DATA
	SZL!CLA!IAC	/SET UP 1 FOR SKIP OF NON-MULTIPLEXED
	CMA!IAC		/MAKE 0 0;MAKE +1 -1 FOR MULTIPLEX DATA
	DAC*	10	/TO USER
	LAC	X0,X	/GET X FOR USER. HARDWARE WORRYS ABOUT
	DAC*	10	/RIGHT-LEFT ALIGNMENT.
	LAC	Y0,X	/AND THE Y CO-ORDINATE.
	DAC*	10

	JMP	FINREQ	/COMMON CODE TO FINISH REQ

/

/	HANDLER INFORMATION FUNCTION

/

HINF	PXA		/UNIT NUMBER FROM XR

	ALSS	6	/PLACE IN FIELD IN AC. AC0=0,

/			/SO 0'S MOVE IN AT BOTTOM OF AC

	AAC	VWINFO	/ADD IN DEVICE INFO.

	JMP	ERRREQ	/USE MECHANISM OF ERROR EXIT

/			/TO RETURN AC CONTENTS TO CALLER

/

/	ATTACH AND DETACH CODE

/

ATTACH	PAL		/AC IS 24 FOR ATTACH, 25 FOR DETACH

	LAC	VWTAB,X	/PDVL NODE ADDRESS FROM OUR TABLE

	DAC*	(R1	/TO SYSTEM REGISTER

	LAC	RWNOD,X	/AND REQUEST NODE ADDRESS

	DAC*	(R2	/TO ANOTHER SYSTEM REG.

	PLX		/PUT 24 OR 25 TO XR FOR FANCINESS.

	XCT	ATDT-24,X  /MAKE CALL TO ATTACH OR DETACH

	JMP	ERRREQ	/IT DIDN'T WORK, PASS ON ERROR CODE

	JMP	FINREQ	/OK, SEND +1 TO USER

ATDT	JMS*	(ALAD	/SYSTEM ATTACH ROUTINE
	JMS*	(DLAD	/SYSTEM DETACH ROUTINE
/
/	CLOSE   MERELY TURNS OFF DEVICE (GET LEAVES IT ON.)
/
CLOSE	DZM	MOD0,X	/CLEAR USAGE BITS
	DZM	RTRN0,X	/CLEAR PARTITION POINTER
	JMS	VWIOCD	/COUNT DOWN XTRA IOCOUNTDOWN
	JMS	HOW	/READJUST DEVICE IOT'S
	JMP	FINREQ	/THAT'S ALL
/

/	THE GET ROUTINE

/

GET	LAC*	10	/MOVE OVER NODE+6

	LAC*	10	/GET NODE+7, CONTROL TABLE ADDR

	JMS	REAL	/CONVERT TO ABS. ADDR FROM RELOC.'ED

/			/RETAIN XR, CHECK IF ADDR OK.

	AAC	-1	/SO WE CAN USE AUTO-INCR AGAIN
	DAC*	(10	/TO GET CONTROL TABLE CONTENTS
	LAC	IOCDW,X	/FIND OUT IF SAME PARTITION AS BEFORE
	SAD	IOCADD	/IOCADD PART. OF THIS CAL. IOCDW,X OF LAST
	JMP	GETA	/SAME, DON'T DO ANYTHING
	JMS	VWIOCD	/COUNT DOWN PREVIOUS ONE
	LAC	IOCADD	/GET THIS ONE
	DAC	IOCDW,X	/SAVE FOR NEXT TIME AROUND
	SMA!SZA		/DON'T COUNT UP UNLESS REAL ADDR. 
	ISZ*	IOCADD	/BUMP I/O COUNTDOWN WORD IN PARTITION BLOCK
GETA	LAC*	10	/TYPE OF GET, 0 OR NON0
	SNA!CLL		/SET UP LINK, 0 FOR NON0 GET
	CML		/AND 1 FOR ZERO TYPE GET
	LAC	PB,X	/20004 (UNIT 0)
	SZL!CLL!IAC	/MAKE IT 4, OR 10002, DEPENDING
	SKP!RAR		/MAKE IT 10002, RE-ESTABLISH 1 LINK
	AND	(776	/MAKE IT 4. LINK REMAINS ZERO
	DAC	POST0,X	/SAY WE WANT AN INTERRUPT
	LAC	MB,X	/NOW CHECK MODE OF THIS DEVICE
	SNL!CLL		/ZERO LINK(CONT. DATA) MUST BE SWAPPED
	SWHA!SKP	/SWAP CONT. DATA, SKIP OVER OTHER OPERATION
	AND	(776	/PEN DATA IS MASKED TO KEEP 100
	SAD	MOD0,X	/HAS MODE CHANGED FOR THIS UNIT??
	JMP	GETC	/NO! DON'T ISSUE ANY IOT'S
	DAC	MOD0,X	/YES, PLACE NEW MODE
	JMS	HOW	/GO ISSUE IOT'S TO REFLECT NEW 

/			/DEMANDS ON THE DEVICE

GETC	LAC*	10	/GET BACK USER ADDR OF RETURN BUFFER

	JMS	REAL	/MAKE ABSOLUTE, CHECK VALIDITY

	AAC	-1	/SO RETURN FROM INTERRUPT CAN USE AUTO.

	DAC	RTRN0,X	/PLACE FOR RETURN CODE. ALSO UNDONE

/			/OPERATION FLAG

	LAC	POST0,X	/FINALLY, TELL INTERRRUPT CODE

	DAC	RQ0,X	/IT CAN ACT ON INTERRUPTS SPECIFIED BY

/			/THE BITS OF THIS MASK

	JMP	VWNXT	/GO LOOK FOR MODE WORK TO DO 

/

/	THE 'REAL' ROUTINE  CONVERTS RELOCATED ADDR.'S TO
/	ABSOLUTE ONES. THE XR IS RESTORED FROM UNITXR 
/	ON EXIT. IF THE ADDR. IS INVALID FOR THE CALLER'S

/	PARTITION A -30 ERROR EXIT IS GIVEN.

REAL	0

	DAC*	(R3	/ADDR IN AC AT CALL TIME TO SYS. REG.

	LAC	RWNOD,X	/GET ADDR OF REQUEST NODE

	DAC*	(R2	/TO ANOTHER SYSTEM REG.
	LAC	(2	/ASSUME 2 AS MAX. TABLE SIZE

	DAC*	(R4	/ANOTHER SYSTEM REGISTER

	JMS*	(VJAX	/ROUTINE PUTS REAL ADDR IN R3

	JMP	REALRR	/ERROR EXIT, CODE IN AC
	LAC	UNITXR	/UNIT # TO XR

	PAX

	LAC*	(R3	/REAL ADDR

	JMP*	REAL	/OUT

REALRR	LAW	-30	/ERROR CODE
	JMP	ERRREQ	/YELL LOUDLY AT CALLER
/
/	VWIOCD DECREMENTS WORD POINTED TO BY IOCDW,X
/  BUT ONLY IF IOCDW,X IS >0. 0 WOULD BE UNUSED, OR EXEC MODE.
/
VWIOCD	0
	LAC	IOCDW,X	/GET THE WORD
	DZM	IOCDW,X	/ZERO IT SINCE WE NO LONGER NEED IT
	DAC	ZOT3	/INTO SUPER TEMPORARY FOR INDIRECTION
	SPA!SNA!CLA!CMA	/SKIP IF REAL ADDR, SET UP -1
	JMP*	VWIOCD	/BAD ADDR (USUALLY 0) JUST EXIT
	.INH		/THINK WE NEED TO HOLD OUT INTERRUPTS
	TAD*	ZOT3	/ADD -1 TO COUNT
	SMA		/CAN'T COUNT BELOW 0
	DAC*	ZOT3	/REPLACE COUNT IF APPLICABLE
	.ENB		/LET THE WORLD IN AGAIN
	JMP*	VWIOCD	/GET OUT

/

/	THE GIVE ROUTINE DOES CLEANUP FOR THE NODE WHOSE

/ ADDRESS IS PROVIDED IN THE AC. THE QUANTITY IN GIVEEV

/ IS PLACED IN THE USER EV (IF ONE) AND AN EVENT

/ DECLARED (IF EV). THE SYSTEM I/O COUNTDOWN IS DONE FOR THE

/ NODE, AND THE NODE IS RETURNED TO THE SYSTEM POOL.

/ THIS ROUTINE CLOBBERS THE AC.

/

GIVEEV	0		/ARGUMENTS PLACED BY CALLER

GIVE	0

	DAC*	(R2	/NODE ADDR IN AC TO SYS. REG.

	TAD	NEGPAG	/FOR N,X TYPE ADDRESSING

	PAX

	LAC	6,X	/ADDR OF EV. IF ONE

	SNA		/SKIP IF THERE REALLY IS ONE

	JMP	GIVE1	/NOPE

	TAD	NEGPAG	/AGAIN PAGE CORRECTION FOR ADDRESSING

	PAX

	LAC	GIVEEV	/CONTENTS FOR EVENT VARIABLE

	DAC	0,X	/THERE THEY GO. MUST USE INDEX OR AUTO.

/			/AS CALLER MAY BE BEYOND 32K!!!!

	LAC	(401000	/DECLARE SIGNIFICANT EVENT

	ISA

GIVE1	LAC	(POOL	/SAY PLACE NODE INTO POOL

	DAC*	(R1	/IN SYSTEM REGISTER
	JMS*	(IOCD	/COUNT DOWN THIS REQUEST
	JMS*	(NADD	/AND GIVE BACK THIS NODE

	JMP*	GIVE	/GET OUT OF HERE

/

/
/	THE HOW ROUTINE ISSUES IOT'S TO REFLECT NEEDS OF TABLET
/ USERS. THERE ARE TWO IOT'S WHICH REQUIRE BITS IN THE AC. THERE
/ ARE FIVE DISTINCT USAGE CASES.
/
/	CONT.	PEN	IOT#1	IOT#2
/	USERS	USERS	703264	703224
/
/	0	0	0	240	CASE 1
/	0	>0	0	621	CASE 2
/	1	0	UNIT	1131	CASE 3 (UNIT BIT 10 FOR UNIT0)
/	1	>0	10	1125	CASE 4 (UNIT BIT 4 FOR UNIT 1)
/	>1	ANY	10	1125	CASE 5 (UNIT BIT 2 FOR UNIT#2
/
/	THE PEN, DATA, OR NONE USAGE OF FOUR UNITS IS SHOWN BY
/ THE FOUR WORDS MOD0-MOD3.
/
/	THE ROUTINE RESTORES XR ON EXIT. CLOBBERS AC AND LIMIT REG.
/
HOW	0
	PXL		/SAVE THE INDEX REG.
	CLX		/THIS AND NEXT SET UP DEFAULT CODE
	AXR	240	/OF 240 IN XR FOR IOT#2 703224
	LAC	MOD0	/ADD UP FOUR STATUS WORDS
	TAD	MOD1
	TAD	MOD2
	TAD	MOD3	/LOW 4 BITS OF AC CASE 3 FOR IOT#1
	SZA!CLL		/SKIP ON NO UNITS (CASE 1)
	AXR	361	/MAKES CODE OF 621 IN CASE WE ARE CASE 2
	TAD	(710300	/LINK ON IF ANY DATA. 400 BIT ON IF ANY PEN.
/			/THE 10 IN LEFT HALF CASE 4-5 IOT#1
	SNL!SWHA!CML	/SKIP ON CASE 345.BRING 400 BIT TO AC0
/			/MAKE CASE 1&2 NOW HAVE LINK ON
	SKP!CLA		/CASE 1,2 CLEAR AC SO NEXT STUFF IS A NO-OP
	AXR	304	/MAKE XR 1125 FOR CASES 4&5
	AAC	300	/400 BIT(ALIAS AC0) 1 IF >1 DATA
	SMA!SNL!SWHA	/CASE 1,2,4 SKIPS, BRING BACK ORIGINAL AC0 BIT
	SPA		/CASE 3 SKIPS, KEEPING ORIGINAL LOW FOUR BITS
	SKP!SWHA	/1,2,4,5 GET IOT#1 BITS FROM LEFT OF AC
	AXR	4	/CASE 3 ADJUST IOT#2 CODE TO 1131
	AND	(17	/LOW FOUR BITS OF AC TO IOT#1
	703264
	PXA		/CODE FROM XR FOR IOT#2
	703224
	PLX		/RESTORE INDEX REGISTER
	JMP*	HOW	/YECH!
/

/

/	IT IS POSSIBLE THAT THERE HAS BEEN A DISCONNECT

/ AND EXIT REQUEST THAT WE HAVE MISSED. WE MUST CHECK

/ THE ASSIGN INHIBIT FLAG OF THE LOWEST NUMBERED VW

/ IN THE SYSTEM.

/

LEAVE	LAC	(VWTAB-1 /SCAN TABLE FOR PDVL NODE

	DAC	UNITXR	/USE THIS AS POINTER
LLL	ISZ	UNITXR	/MOVE TO NEXT TABLE ENTRY

	LAC*	UNITXR	/GET NODE ADDR, IF ONE THERE

	SNA		/SKIP IF REAL ONE

	JMP	LLL	/NOPE, GET NEXT ONE

	TAD	NEGPAG	/NEGATIVE OF HANDLER PAGE BITS

	PAX		/FOR N,X TYPE ADDRESSING

	LAC	11,X	/ASSIGN INHIBIT FLAG

	SMA		/SKIP IF HAS BEEN SET

	JMP	WAIT	/HAS NOT BEEN SET, GO WIAT

ELEX	LAC	(400004	/RAISE OURSELVES TO LEVEL 5

/			/SO THE CLEAN UP JOB IS NOT

/			/DISTURBED
	ISA

	DZM	RQ0	/REFUSE TO SERVICE INTERRUPTS

	DZM	RQ1

	DZM	RQ2
	DZM	RQ3
	LAC	(242	/TURN OFF TABLET, SINCE WE ARE LEAVING
	703224
	LAW	-24	/CODE TO SAY HANDLER ASSIGNED AAWAY
/			/IF WE HAVE NODES OUTSTANDING
	DAC	GIVEEV	/ARGUMENT FOR NODE GIVER-BACKER
	DZM	UNITXR	/KEEP XR FOR UNIT # IN HERE FOR CLEAN UP LOOP
	SKP		/MISS ISZ AT LOOP TOP
ELL	ISZ	UNITXR	/MOVE ON TO NEXT UNIT
	LAC	UNITXR	/XR MAY HAVE BEEN WIPEN OUT, RESTORE IT
	PAX
	LAC	VWTAB,X	/GET AN ENTRY FROM UNIT TABLE
	SPA		/SKIP IF REAL OR EMPTY
	JMP	EXIT	/MINUS, FINISHED TABLE, EXIT
	SNA		/SKIP IF REAL ONE
	JMP	ELL	/EMPTY UNIT, GO BACK TO TOP
	AAC	6	/NODE+6 IS QUEUE TOP FOR REQ.'S
	DAC	ZOT	/HOLD THIS FOR LATER LOOP
	IAC		/NODE+7 TO . . 
	DAC*	(10	/AUTO INCR.
	DZM*	10	/TO CLEAR TRIGGER AT NODE+10
	DZM*	10	/AND ASSIGN INHIBIT AT NODE+11
	JMS	VWIOCD	/COUNT DOWN XTRA I/OCOUNTDOWN FOR THIS PARTITION
	LAC	RWNOD,X	/SEE IF OUTSTANDING OPERATION
	SZA		/SKIP IF NOT
	JMS	GIVE	/YES, GO CLEAN IT UP

/			/WE DQUEUE'D IT BUT OPERATION NEVEN COMPLETED

EEL	LAC	ZOT	/TOP OF LIST ADDR

	DAC*	(R1	/DEQUEUE A NODE FROM THIS LIST

	JMS*	(PICK	/DIMILAR TO DQRQ

	JMP	ELL	/NO MORE IN THIS LIST, GO CHECK

/			/NEXT PHYSICAL DEVICE

	JMS	GIVE	/GIVE . HELLO, I/O COUNTDOWN ON THIS NODE???

	JMP	EEL	/GO GT NEXT NODE FROM LIST

/

EXIT	DBK		/KICK BACK TO LEVEL 7

DISC	ISZ	VWCON	/MAKE CONNECT CODE DISCONNECT CODE

	CAL	VWCON	/AND DISCONNECT API SLOT

	CAL	(10	/GO BACK TO THE SYSTEM

/

/

/	ABORT CODE

/
/	THIS CODE IS TO ABORT A SPECIFIC TASK IN A SPECIFIC

/ PARTITION, BUT LEAVE THE HANDLER OPERATING.

/

ABORT	XOR	VWEV	/CLEAR OUT THE ABORT BIT

	DAC	VWEV	/REPLACEING EVENT VARIABLE

	.ENB		/ENABLE INTERRRUPTS, WERE DISABLED BEFORE.

	CLX		/SET UP TO LOOK FOR FIRST DEVICE.

ALL	AXR	1	/INTO WHOSE QUEUE THE ABORT REQ. WAS PLACED
	LAC	VWTAB-1,X /IRREGARDLESS OF WHICH UNIT IT WAS

/			/REALLY FOR

	SNA		/SKIP IF THE REAL NODE

	JMP	ALL	/GO CHECK NEXT (IF VW1 BUT NOT VW0) I GUESS

/			/THAT'S POSSIBLE.

	DAC*	(R1	/SET UP TO DEQUEUE ABORT NODE

	JMS*	(DQRQ	/MONITOR DEQUEUEING ROUTINE
	JMP	WAITR	/DIDN'T FIND IT, BAD! CHECK OTHER UNITS

	DAC	ZOT	/SAVE ABORT NODE ADDR

	TAD	NEGPAG	/ADDRESSING, CHECK IF

	PAX		/REALLY ABORT NODE

	LAC	5,X	/BY ITS REQUEST TYPE

	SAD	(17	/ABORT CODE 17 ON LUN 0!

	SKP		/IT CHECKS OUT OK

	JMP	VWUNIM	/TREAT AS UNIMPLEMENTED CODE ERROR

	LAC	3,X	/THESE ADDRESSIN GAMES TO TELL WHETHER

	TAD	NEGPAG	/EXITTING PARTITION HAS ONE OR MORE

	PAX		/REQUESTS OUTSTANDING WITH US

	LAC	4,X	/PARTITION BASE ADDR. WE KEEP RTRN0

	CMA!IAC		/AS A WHO HAS A REQUEST OUTSTANDING

	DAC	ZOT1	/FLAG. -BASE TO ZOT1 FOR EASY TESTING

	LAC	5,X	/AND NOW THE PARITITION SIZE

	CMA!IAC

	DAC	ZOT2	/IT TOO MINUS FOR EASY TESTING

	LAW	-4	/LOOP CONTROL WITH UNITXR

	DAC	UNITXR

ALL1	LAC	UNITXR	/PLACE XR=0 WHEN UNITXR=-4

	AAC	4	/THIS STRANGE LOOP CONTROL SINCE GIVE

	PAX		/WILL RUIN THE XR

	LAC	RTRN0,X	/DOES PRESENT PARTITION AGREE WITH THIS

	TAD	ZOT1	/LOWER LIMIT CHECK

	SPA		/SKIP IF STILL COULD BE

	JMP	ALL2	/ADDRESS TOO SMALL, GO TO LOOP CONTROL

	TAD	ZOT2	/UPPER LIMIT CHECK

	SMA		/SKIP IF GOT ONE
	JMP	ALL2	/ADDRESS TOO BIG

	DZM	RQ0,X	/REFUSE TO SERVICE HIS INTERRUPT
	DZM	POST0,X	/ZERO THIS SO ANOTHER USER CAN GET IN
	JMS	VWIOCD	/DO XTRA COUNTDOWN WE PLACED IN SO WE
/			/WOULD GET CALLED AT ABORT TIME
	DZM	RTRN0,X	/JUST IN CASE ANOTHER ABORT SOON
	LAC	RWNOD,X	/GET BACK REQUEST NODE STILL HANGING
	DZM	RWNOD,X	/NECESSARY
	DZM	MOD0,X	/THIS UNIT NO LONGER IN USE!
	SZA		/SKIP IF NO NODE OUTSTANDING
	JMS	GIVE	/RETURN NODE, DO COUNTDWN. EV TO ABORT'D
/			/TASK IS ESSENTIALLY A NO-OP

ALL2	ISZ	UNITXR	/FUNNY LOOP CONTROL SINCE XR GOT ZAPPED
	JMP	ALL1	/NOT DONE YET
	JMS	HOW	/READJUST IOT'S FOR NEW CONDITION.

	LAC	(VWTAB-1 /SCAN THRU PHYSICAL DEVICES TO RELEASE

	DAC	UNITXR	/THEIR NODES FROM THIS PARTITION

DQLP	ISZ	UNITXR	/THESE NODES ARE THOSE THAT DIDN'T GET TO

	LAC*	UNITXR	/US YET. GET DEVICE

	SPA		/SKIP IF REAL ONE OR EMPTY SLOT

	JMP	DQABO	/THRU WITH TABLE, GO GIVE BACK ABT NODE

	SNA		/SKIP IF REAL ONE

	JMP	DQLP	/EMPTY SLOT, KEEP TRYING

	DAC*	(R1	/PDVL NODE ADDRESS

	LAC	ZOT	/THE ABORT NODE ADDRESS

	DAC*	(R2	/ANOTHER SYSTEM REGISTER

	JMS*	(DMTQ	/THE ROUTINE TO EMPTY ALL REQUESTS

/			/CORRESPONDING TO THE PARTITION OF THE

/			/ABT. NODE FROM THIS QUEUE.

	JMP	DQLP	/GO TO NEXT PHYSICAL DEVICE

DQABO	CLA!IAC		/+1 TO EVENT VARIABLE OF ABORTER

	DAC	GIVEEV	/ARGUMENT OF GIVE ROUTINE

	LAC	ZOT	/GIVE WANTS NODE ADDR IN AC
	JMS	GIVE	/GIVE BACK ABT NODE, EV, DECLARE EVENT.

	JMP	WAITR	/RESTART AT LOOP TOP. NECESSARY????

/

/  INTERRUPT LEVEL CODE

/
VWINT	0		/API ENTRY

	DBA		/ENTER INDEX ADDRESSING MODE

	DAC	SAVAC	/SAVE INTERRUPTED AC

	703272		/GET STATUS FROM WRITING TABLETS

	DAC	STATS	/AND SAVE THAT ALSO (TIME CHEAPER THA

/			/REISSUING IOT EACH TIME NEED IT.
	SMA!CLL!RAL	/SKIP IF DATA READY. CLEAR LINK IN CASE. MOVE
/			/PEN DATA BIT TO AC0 FOR CHECKING

	SMA!CLA!CLL	/DATA NOT READY!?!WE REALLY SHOULDN'T GET 

/			/HERE. CLEAR ALL SO EXIT THRU VWBAD. IN MEAN

/			/TIME, CLEAR PEN DATA IF NECESSARY

	SPA!RTL		/SKIP OVER CLEAR PEN DATA IF FLOP NOT SET.

/			/ALSO MOVE TABLET0 BIT TO LINK FOR TEST.

	703221		/CLEAR PEN DATA FLAG

	SZL!RAL		/SKIP IF NOT TABLET ZERO, MOVE NEXT BIT IN.

	JMP	TAB0	/IT'S TABLET ZERO. GO DO IT

	SZL!RAL		/SKIP IF NOT TABLET 1; MOVE IN NEXT BIT

	JMP	TAB1	/GOT TABLET 1

	SZL!RAL		/SKIP IF NOT TABLET 2

	JMP	TAB2	/GOT TABLET 2

	SNL!RAL		/SKIP IF TABLET 3

VWBAD	JMP	VWOUT	/ERROR. EITHER DATA READY NOT SET (SEE ABOVE)

/			/OR NONE OF TABLET FLAGS SET.
TAB3	AND	RQ3	/WHICH INTERRUPTS ARE WANTED? RQ3 CAN BE 0,
/			/100020, OR 40. 0 SAYS NONE WANTED. 40

/			/SAYS ANY WANTED (DATA READY NOW IN THIS POSITION
/			/100020 SAYS ONLY PEN DATA. TO BE ACTIVATED

/			/PEN PEN DATA FLAG OR SINGLE POINT FLAG.

	SNA!CLA!IAC	/SKIP IF WE GOT RIGHT ONE

	JMP	VWOUT	/WE DIDN'T, CLEAR DATA READY AND EXIT

	DZM	RQ3	/HONOR NO MORE INTERRUPTS!
	DAC	VWEV	/SET ONE INTO EVENT VARIABLE
	703232		/READ X POSITION

	DAC	X3	/AGAIN HOLD THE X POSITION

	703252		/GET THE Y POSITION
	DAC	Y3
	LAC	STATS	/HOLD STATUS BY UNIT # FOR CAL LEVEL
	DAC	ST3	/LEAVE STATUS IN AC FOR VWCM
	JMP	VWCM	/JOIN REST FOR COMMON CLEAN UP
TAB2	AND	RQ2	/WHICH ONES ARE WANTED BY TABLET 2.
/			/BIT POSITIONS: 0,40010,20.

	SNA!CLA!IAC	/GOT ONE? SET UP 1 FOR VWEV

	JMP	VWOUT	/NOPE, JUST LEAVE

	DZM	RQ2	/HONOR NO MORE REQUESTS

	DAC	VWEV	/SET EVENT VARIABLE
	703232		/X
	DAC	X2

	703252		/Y
	DAC	Y2
	LAC	STATS
	DAC	ST2
	JMP	VWCM
TAB1	AND	RQ1	/BITS: 0,20004,10.

	SNA!CLA!IAC
	JMP	VWOUT
	DZM	RQ1
	DAC	VWEV
	703232

	DAC	X1

	703252
	DAC	Y1
	LAC	STATS
	DAC	ST1

	JMP	VWCM
TAB0	AND	RQ0	/BITS: 0,10002,4.

	SNA!CLA!IAC

	JMP	VWOUT
	DZM	RQ0
	DAC	VWEV
	703232

	DAC	X0

	703252
	DAC	Y0
	LAC	STATS
	DAC	ST0
VWCM	SWHA		/SINGLE POINT MODE BIT FROM 400 TO AC0
	SPA!CLA		/IF SINGLE POINT, DON'T SKIP SO WE CAN
	703264		/CLEAR ALL TABLETS
	LAC	(401000	/DECLARE SIGNIFICANT EVENT

	ISA		/TO WAKE HANDLER AT CAL LEVEL

VWOUT	703241		/CLEAR DATA READY FLAG

	LAC	SAVAC	/BRING BACK INTERRUPTED AC

	DBR		/DEBREAK AND RESTORE

	JMP*	VWINT	/OUT!!

/
/
/  INTERRUPT LEVEL TEMPORARY LOCATIONS
/

SAVAC	0		/HOLD INTRRUPTED AC

STATS	0		/HOLD TABLET STATUS WHILE

/			/PLAYING WITH BITS IN AC

/

/

/	CORE LOCATIONS ETC.

/

NEGPAG	0		/NEGATIVE PAGE BITS FOR HANDLER LOCATION

VWEV	0		/EVENT VARIABLE FOR HANDLER
UNITXR	0		/POINTER USUALLY FOR SCAN THRU VWTAB

VWTAB	0		/FOUR UNIT TABLE FOR PDVL'S FOR FOUR

	0		/UNITS ORDERED BY UNIT #

	0

	0

	-1		/END OF TABLE STOPPER
MB	10100		/DATA MODE SETTING FOR MOD0, SWAPPED
	4100		/DATA MODE SETTING FOR MOD1, SWAPPED
	2100		/DATA MODE SETTING FOR MOD2,SWAPPED
	1100		/DATA MODE SETTING FOR MOD2, SWAPPED
PB	20004		/BITS FOR MAKING POST, RQ WORDS FOR UNIT0
	40010		/AND FOR UNIT 1
	100020		/UNIT 2
	200040		/UNIT 3

/

/	CAL'S FOR VARIOUS THINGS

VWAIT	20		/WAIT FOR HANDLER EVENT VARIABLE.

	VWEV

/

VWCON	11		/CONNECT VW TO API

	VWEV		/EVENT VARIABLE

	33		/API LINE -40

	VWINT		/INTERRUPT ROUTINE ADDR
	.END	VWA	/ZXCV
