;; PrintMc.mu - Press Microcode -- "Print Microcode" (Print pass)

; Last modified by Bob Hunt March 26, 1981  2:47 PM
; modified I/O address of TC200 Interface, no longer uses Diablo Port
; last modified by Butterfield, October 17, 1980  5:11 PM
; - defined X10, X13, and X21 trap locations - 10/17/80

%0, 1777, 637, TRAPX10;  X10 microcode locn of TRAP
%0, 1777, 645, TRAPX13;  X13 location
%0, 1777, 37, TRAP1;  X21 location

#SlotMc.Mu;
#DispatchMc.Mu;

; PrintVersatecTrap
; Ac0 => pointer to buffer for scan line
; Ac1 = count of bytes to spit out.

!1,2,VLOOP,VDONE;
!1,2,SB2,SBDONE;

$VAL1	$R15;
$VAL2	$R16;
$PCOMM	$R70;
$OUTADR	$R67;

TRP0: T←4000;
	L←10000+T, TASK;
	PCOMM←L;	**
	T←177000;
	L←16+T, TASK;
	OUTADR←L;	**

TRPC: L←AC1-1, BUS=0, TASK;
	AC1←L, :VLOOP;	**

VLOOP:	MAR←AC0;
	L←AC0+1;
	AC0←L;
	T←ALLONES;
	L←MD XOR T;
	VAL2←L, TASK;		Right 8 bits here
	VAL1←L LCY 8;	** Left 8 bits here

SB1:	T←377;
	T←VAL1.T;
	L←PCOMM+T;		PiClkBit+NotPrintBit
	MAR←OUTADR;
	T←10000;
	MD←LREG;
	MAR←OUTADR;
	L←LREG XOR T;
	MD←LREG;
	MAR←OUTADR;
	L←LREG XOR T, TASK;
	MD←LREG;	**

	L←AC1-1, BUS=0, TASK;
	AC1←L, :SB2;

SB2:	T←377;
	T←VAL2.T;
	L←PCOMM+T;		PiClkBit+NotPrintBit
	MAR←OUTADR;
	T←10000;
	MD←LREG;
	MAR←OUTADR;
	L←LREG XOR T;
	MD←LREG;
	MAR←OUTADR;
	L←LREG XOR T, TASK;
	MD←LREG, :TRPC;	**

VDONE:	:BCPLRET;
SBDONE:	:BCPLRET;
;

;
; PrintHgTrap
; AC0 = # bytes to try to spit out
; AC1 = Pointer to end of buffer +1
; Returns in AC0 the number of bytes remaining to spit out

$INADR	$R70;
$ABITS	$40000;	First send: extConnect + data
$BBITS	$400;		Then XOR this (dataStrobe)

!1,2,HGB1,HGB2;
!1,2,HGB1A,HGDONE;
!1,2,HGB1B,HG1DONE;
!1,2,HGB2B,HG2DONE;

TRP1: T←177000;
	L←101+T;
	OUTADR←L;
	L←100+T, TASK;
	INADR←L;	**
	L←AC0;		Number of bytes remaining
	VAL1←L RSH 1;	Convert to number of words
	T←VAL1;
	L←AC1-T-1, TASK;
	AC1←L;	** Pointer to first word -1
	MAR←AC1;
	T←377;
	L←MD AND T, TASK;
	VAL2←L;	** In case first is odd byte

; Main loop. AC0 = number of bytes remaining to do.

HGB:	L←AC0-1, BUSODD;
	AC0←L, :HGB1;

; Sending VAL1 (high-order byte)
HGB1:	MAR←L←AC1+1, SH<0;	Test for all done (AC0=-1)
	AC1←L, :HGB1A;
HGB1A:	T←377;
	L←MD;
	VAL1←L LCY 8;
	L←LREG AND T;
	VAL2←L;
	L←VAL1 AND T, TASK;
	VAL1←L;	**

	MAR←INADR;	Check to see if FIFO empty (sign bit=0)
	T←ABITS;
	L←MD;
	L←VAL1+T, SH<0;
	VAL1←L, :HGB1B;
HGB1B:	MAR←OUTADR;
	T←BBITS;
	MD←VAL1;		Ship value to Hg
	MAR←OUTADR;
	L←VAL1 XOR T, TASK;
	MD←LREG;	** Ship value to Hg with dataStrobe on
	MAR←OUTADR;
	NOP;
	MD←VAL1, :HGB;

; Sending VAL2 (low-order byte)
HGB2:	MAR←INADR;
	T←ABITS;
	L←MD;
	L←VAL2+T, SH<0;
	VAL2←L, :HGB2B;
HGB2B:	MAR←OUTADR;
	T←BBITS;
	MD←VAL2;		Ship value to Hg
	MAR←OUTADR;
	L←VAL2 XOR T, TASK;
	MD←LREG;	** Ship value to Hg with dataStrobe on
	MAR←OUTADR;
	NOP;
	MD←VAL2, :HGB;

HGDONE:	L←MD, :HG1DONE;
HG1DONE:	L←AC0+1, :HGXIT;
HG2DONE:	L←AC0+1;
HGXIT:	AC0←L, :BCPLRET;

; Unused traps:

TRP2: NOP, :BUMTRAP;
TRP3: NOP, :BUMTRAP;
TRP4: NOP, :BUMTRAP;
TRP5: NOP, :BUMTRAP;
TRP6: NOP, :BUMTRAP;
TRP7: NOP, :BUMTRAP;