File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / d / entry / adwc.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:24:19 2019 UTC (7 years ago) by root
Branches: bsd, MAIN
CVS tags: v12b, v121, HEAD
Power 6/32 Unix version 1.2b

#define disp_error error

/*		standard definition file				*/
/*		for 'C' diagnostic porgrams.				*/
/*									*/
/*									*/
#define		HIGH		31
#define		IPL		8
#define		PSWMASK		0xf
#define		T		16
#define		IV		32
#define		FU		64
#define		DV		128
#define		FLAGS		0x0000000f

extern long scoplp;
extern long force_lp;

asm(".set  PSWMASK,0xf");


/*		constants definition for ADWC instruction		*/
/*									*/
/*									*/

#define		ADWC	0x8d		/*opcode			*/


#define		MAX_PATTERNS	6


#define		SUM1		0		/*initial value of sum	*/
#define		SUM2		-1
#define		SUM3		0x7fffffff
#define		SUM4		0x7ffffffd
#define		SUM5		0x80000000
#define		SUM6		0x80000000


#define		ADD1		-1		/*initial values for add*/
#define		ADD2		1
#define		ADD3		1
#define		ADD4		1
#define		ADD5		0x7fffffff
#define		ADD6		0x80000000



#define		EXP1		0		/*expected result	*/
#define		EXP2		1
#define		EXP3		0x80000000
#define		EXP4		0x7fffffff
#define		EXP5		0
#define		EXP6		0


#define		IPSW1		1		/*initial psw		*/
#define		IPSW2		15
#define		IPSW3		0
#define		IPSW4		15
#define		IPSW5		15
#define		IPSW6		0


#define		EPSW1		5		/*expected psw		*/
#define		EPSW2		1
#define		EPSW3		2
#define		EPSW4		0
#define		EPSW5		5
#define		EPSW6		15


#define		ERROR1		1		/*error definitions	*/
#define		ERROR2		2
#define		ERROR3		3


#define		EM1		"sum not equal to expected \n"
#define		EM2		"addend operand altered \n"
#define		EM3		"psw not equal to expected \n"




/*	Global variables for add with carry test			*/
/*									*/
/*									*/

static short	index = 0;
static long	sum = 0;	/*destination location			*/
static long	add = 0;	/*addend location			*/
static long	psw;		/*processor status word			*/
static long	error_count = 0;

				/*initial flag values			*/
static long	i_psw[MAX_PATTERNS] = {IPSW1,IPSW2,IPSW3,IPSW4,IPSW5,IPSW6};
				/*expected flag values			*/
static long	exp_psw[MAX_PATTERNS] = {EPSW1,EPSW2,EPSW3,EPSW4,EPSW5,EPSW6};
				/*expected destination			*/
static long	exp[MAX_PATTERNS] = {EXP1,EXP2,EXP3,EXP4,EXP5,EXP6};
				/*sum values				*/
static long	s[MAX_PATTERNS] = {SUM1,SUM2,SUM3,SUM4,SUM5,SUM6};
				/*add values				*/
static long	a[MAX_PATTERNS] = {ADD1,ADD2,ADD3,ADD4,ADD5,ADD6};


static long savvec4;
static long old_psw;


adwc()
{
      asm("movl	$2,_no_opr");
      for (index = 0; index < MAX_PATTERNS; index++) t_adwc();
      asm("jmp *return");
}	


static t_adwc()
{	char *msg;
	for(;;)
	  { 
	   asm("a1:	movab	a1,_stpc");
	   sum = s[index];	/*initialize sum, addend, & psw	*/
	   add = a[index]; 
	   asm("movw	_index,r11");
	   asm("shll	$16,_i_psw[r11],_savvec4");
	   asm("bicpsw	$PSWMASK");
	   asm("movpsl	_old_psw");	

	   if (index==0) {
		setjmp();
		asm("movl	$1,_subtst");
	   	asm("bispsw	_savvec4");	/* mem to mem */
	   	asm("adwc	_add,_sum");
	   	asm("movpsl	_psw");		/*save psw		*/
		}
	   if (index==1) {
		setjmp();
		asm("movl	$2,_subtst");
		asm("movl       _add,r6");	/* reg to mem */
	  	asm("bicpsw	$PSWMASK");
	   	asm("bispsw	_savvec4");
	   	asm("adwc	r6,_sum");
	   	asm("movpsl	_psw");		/*save psw		*/
		asm("movl       r6,_add");
		}
	   if (index==2) {
		setjmp();
		asm("movl	$3,_subtst");
		asm("movl       _sum,r7");	/* mem to reg */
	   	asm("bicpsw	$PSWMASK");
	   	asm("bispsw	_savvec4");
	   	asm("adwc	_add,r7");
	   	asm("movpsl	_psw");		/*save psw		*/
		asm("movl       r7,_sum");
		}
	   if (index==3) {
		setjmp();
		asm("movl	$4,_subtst");
	   	asm("movl       _add,r6");	/* reg to reg */
		asm("movl       _sum,r7");
	   	asm("bicpsw	$PSWMASK");
	   	asm("bispsw	_savvec4");
	   	asm("adwc	r6,r7");
	   	asm("movpsl	_psw");		/*save psw		*/
		asm("movl       r6,_add");
		asm("movl       r7,_sum");
			 }
	   if (index==4) {
		setjmp();
		asm("movl	$5,_subtst");
	   	asm("bicpsw	$PSWMASK");
	   	asm("bispsw	_savvec4");	/* mem to mem */
	   	asm("adwc	_add,_sum");
	   	asm("movpsl	_psw");		/*save psw		*/
		}
	   if (index==5) {
		setjmp();
		asm("movl	$6,_subtst");
	   	asm("bicpsw	$PSWMASK");
	   	asm("bispsw	_savvec4");	/* mem to mem */
	   	asm("adwc	_add,_sum");
	   	asm("movpsl	_psw");		/*save psw		*/
		}
	   psw &= FLAGS;	/*mask out all bits except flag bits	*/
	   if (sum != exp[index])
		{
		asm("movl	$1,_ercode");
		if (scoplp) longjmp();
		disp_error(sum,exp[index],a[index],s[index]);
		}
	   if (add != a[index])
		{
		asm("movl	$3,_ercode");
		if (scoplp) longjmp();
		disp_error(add,a[index],a[index],s[index]);
		}
	   if (psw != exp_psw[index])
		{
		asm("movl	$2,_ercode");
		if (scoplp) longjmp();
		disp_error(psw,exp_psw[index],a[index],s[index]);
		}
    	   else
		if (force_lp) longjmp();
		return(0);	 
          }
}


unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.