{ File Name: ChainSub.mc
  
  This file contains subroutines used for ChainBlt.mc.
  1. SaveChainReg - save registers for ChainBlt.
  2. RestoreChainReg - restore all registers for ChainBlt.
  
  Author: MYT
  Created: July 30, 1986
  last edited: Oct. 6 (change dstWidth to bitWidth)
}

{ Copyright (C) 1986 by XEROX corporation. All rights reserved.}

{****************************************************************************************
SaveChainReg: Save register before call some other routine.
	      L2 is caller
	      First ccle - c2
	      Last ccle - c2
	      3 1/3 clicks
*****************************************************************************************}


SaveChainReg:

	USavelength ← length,				c2;
	USavecount ← bitWidth,				c3;
	USavedstbit ← DBit,				c1;
	USavechainbasel ← rchainbasel,			c2;
	USavewritebit ← writebit,			c3;
	USavedstlow ← rdstlow,				c1;
	Q ← rhchainbaseh, 				c2;
	USavechainbaseh ← Q,				c3;
	Q ← rhdsthigh, pRet2, 				c1;
	USavedsthigh ← Q, RET[SaveChainRegRet],		c2;
	
	
{****************************************************************************************
RestoreChainReg: Restore registers.
	      L5 is caller
	      First ccle - c1
	      Last ccle - c1
	      3 1/3 clicks
*****************************************************************************************}
RestoreChainReg:
	
	length ← USavelength,				c1;
	bitWidth ← USavecount,				c2;
	DBit ← USavedstbit,				c3;
	rchainbasel ← USavechainbasel,			c1;
	writebit ← USavewritebit,			c2;
	rdstlow ← USavedstlow,				c3;
	Q ← USavechainbaseh, 				c1;
	rhchainbaseh ← Q LRot0,				c2;
	Q ← USavedsthigh, pRet5,			c3;
	rhdsthigh ← Q LRot0,RET[RestoreChainRegRet],	c1;