File:  [Power 6/32 Unix Tahoe 4.2BSD] / cci / d / entry / mneg.c
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs
Sun Jul 28 12:30:42 2019 UTC (6 years, 11 months ago) by root
Branches: bsd, MAIN
CVS tags: v121, HEAD
Power 6/32 Unix version 1.21

/*	Global variables for mnegl test					*/
/*									*/
/*									*/


/*	constants definition for mneg instructions test			*/
/*									*/
/*									*/

#define		FLAGS			0xf
asm(".set FLAGS,0xf");
#define		MNEGB			0xe8	  /*opcodes		*/
#define		MNEGW			0xea
#define		MNEGL			0xec

extern long scoplp;
extern long force_lp;

#define		MAX_PATTERNS		6	   /*max test patterns	*/

#define		INITIALB		0xffffff00 /*initialization	*/
#define		INITIALW		0xffff0000 /*values for desti-	*/
#define		INITIALL		0xaaaaaaaa /*nation		*/

#define		SB1			0x80	   /* -128 */
#define		SW1			0x8000
#define		SL1			0x80000000

#define		SB2			0x00	   /* 0    */
#define		SW2			0x0000
#define		SL2			0x00000000

#define		SB3			0x7f	   /* +127 */
#define		SW3			0x7fff
#define		SL3			0x7fffffff

#define		SB4			0x01	   /* +1   */
#define		SW4			0x0001
#define		SL4			0x00000001

#define		SB5			0x81	   /* -127 */
#define		SW5			0x8001
#define		SL5			0x80000001

#define		SB6			0xff	   /* -1   */
#define		SW6			0xffff
#define		SL6			0xffffffff

#define		EB1			0xffffff80 /*expected data*/
#define		EW1			0xffff8000
#define		EL1			0x80000000
#define		EB2			0xffffff00
#define		EW2			0xffff0000
#define		EL2			0x00000000
#define		EB3			0xffffff81
#define		EW3			0xffff8001
#define		EL3			0x80000001
#define		EB4			0xffffffff
#define		EW4			0xffffffff
#define		EL4			0xffffffff
#define		EB5			0xffffff7f
#define		EW5			0xffff7fff
#define		EL5			0x7fffffff
#define		EB6			0xffffff01
#define		EW6			0xffff0001
#define		EL6			1


	
#define		FLG1			4	   /*initial flag val*/
#define		FLG2			11
#define		FLG3			6
#define		FLG4			6
#define		FLG5			14
#define		FLG6			14


#define		EFLG1			2	  /* expected flag val */
/* #define	EFLG1			10 	  old expected flag val */
#define		EFLG2			5
#define		EFLG3			8
#define		EFLG4			8
#define		EFLG5			0
#define		EFLG6			0

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

						  /*error messages	*/
#define		EM1	"destination not equal to expected \n"
#define		EM2	"source altered by the instruction \n"
#define		EM3	"flags not equal to expected \n"





static long	dest = 0;	/*destination location			*/
static long	source = 0;	/*source location			*/
static long	error_count = 0;
static long	psw;		/*processor status word			*/

static long	index = 0;	/*array index				*/

static long	expl[MAX_PATTERNS] = {EL1,EL2,EL3,EL4,EL5,EL6};
static long	expw[MAX_PATTERNS] = {EW1,EW2,EW3,EW4,EW5,EW6};
static long	expb[MAX_PATTERNS] = {EB1,EB2,EB3,EB4,EB5,EB6};
				/*expected values			*/

static long	flag_value[MAX_PATTERNS] = {FLG1,FLG2,FLG3,FLG4,FLG5,FLG6};
				/*flag values for initialization	*/

static long	exp_psw[MAX_PATTERNS] = {EFLG1,EFLG2,EFLG3,EFLG4,EFLG5,EFLG6};
				/*expected psw				*/

static long	sourcel[MAX_PATTERNS] = {SL1,SL2,SL3,SL4,SL5,SL6};
static long	sourcew[MAX_PATTERNS] = {SW1,SW2,SW3,SW4,SW5,SW6};
static long	sourceb[MAX_PATTERNS] = {SB1,SB2,SB3,SB4,SB5,SB6};
				/*source values				*/
static long savvec4;
static char *msg, *title;
static short init_flg;

mneg()
{
	asm("movl	$2,_no_opr");	/* two operands in use */
	title = "** MNEGL **\n";
	mnegl();

	title = "** MNEGW **\n";
	mnegw();

	title = "** MNEGB **\n";
	mnegb();
	asm("jmp *return");
}

static mnegl()			/* move negated long test */
{
   for (index=0; index<MAX_PATTERNS; index++) t_mnegl ();
}


static	t_mnegl()
{	long *lptr, op1, op2, exp_dest, exp_flg;

	for(;;)
	  { 
	   setjmp();
	   asm("mn1:	movab	mn1,_stpc");
	   op2 = dest = INITIALL;	/* Init destination, source, & psw */
	   lptr = sourcel+index;
	   op1 = source = *lptr;	/* do not use index */
	   init_flg = (short)flag_value[index];

	if (index==0) {
	   asm("movl	$0x1,_subtst");
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_init_flg");
	   asm("mnegl	_source,_dest");/* memory to memory */
	   asm("movpsl	_psw");		/* Save psw	*/
		   }
	if (index==1) {
	   asm("movl	$0x2,_subtst");
	   asm("bicpsw	$FLAGS");
	   asm("movl	_dest,r7");	/* load destination register */
	   asm("bispsw	_init_flg");
	   asm("mnegl	_source,r7");	/* memory to register */
	   asm("movpsl	_psw");		/* Save psw	*/
	   asm("movl	r7,_dest");	/* restore check location */
		   }
	if (index==2) {
	   asm("movl	$0x3,_subtst");
	   asm("bicpsw	$FLAGS");
	   asm("movl	_source,r6");	/* load source register */
	   asm("bispsw	_init_flg");
	   asm("mnegl	r6,_dest");	/* register to memory */
	   asm("movpsl	_psw");		/* Save psw	*/
		   }
	if (index==3) {
	   asm("movl	$0x4,_subtst");
	   asm("bicpsw	$FLAGS");
	   asm("movl	_source,r6");	/* load source register */
	   asm("movl	_dest,r7");
	   asm("bispsw	_init_flg");
	   asm("mnegl	r6,r7");	/* register to register */
	   asm("movpsl	_psw");		/* Save psw	*/
	   asm("movl	r7,_dest");	/* load result into dest */
		   }
	if (index==4) {
	   asm("movl	$0x5,_subtst");
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_init_flg");
	   asm("mnegl	_source,_dest");/* memory to memory */
	   asm("movpsl	_psw");		/* Save psw	*/
		   }
	if (index==5) {
	   asm("movl	$0x6,_subtst");
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_init_flg");
	   asm("mnegl	_source,_dest");/* memory to memory */
	   asm("movpsl	_psw");		/* Save psw	*/
		   }
	   psw &= FLAGS;		/* Get flags	*/
	   lptr = expl+index;
	   exp_dest = *lptr;
	   if (dest != exp_dest)
		{
		asm("movl	$1,_ercode");	/* error data miscompare */
		if (scoplp) longjmp();
	        error(dest,exp_dest,op1,op2);
		} 
	   if (source != op1)
		{
		asm("movl	$3,_ercode");	/* error operand miscompare */
		if (scoplp) longjmp();
	        error(source,op1,op1,op2);
		}
	   lptr = exp_psw+index;
	   exp_flg = *lptr; 
	   if (psw != exp_flg)
		{
		asm("movl	$2,_ercode");	/* error flag miscompare */
		if (scoplp) longjmp();
	        error(psw,exp_flg,op1,op2);
		}
		if (force_lp) longjmp();
	  break;
          }
}



static mnegw()			/* move negated word test */
{
      for (index = 0; index < MAX_PATTERNS; index++) t_mnegw();
}

static t_mnegw()
{
	for (;;)
	  { 
	   setjmp();
	   asm("mn2:	movab	mn2,_stpc");
	   dest = INITIALW;	/*initialize destination, source, & psw	*/
	   source = sourcew[index];
	   asm("movw	_index,r11");
	   asm("shll 	$16,_flag_value[r11],_savvec4");

	if (index==0) {
	   asm("movl	$0x7,_subtst");
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_savvec4");
	   asm("mnegw	_source+2,_dest+2");	/* memory to memory	*/
	   asm("movpsl	_psw");			/* Save psw		*/
	    	   }
	if (index==1) {
	   asm("movl	$0x8,_subtst");
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_savvec4");
	   asm("movl	_source,r6");		/* load source register */
	   asm("mnegw	r6,_dest+2");	/* register to memory	*/
	   asm("movpsl	_psw");			/* Save psw		*/
	    	   }
	if (index==2) {
	   asm("movl	$0x9,_subtst");
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_savvec4");
	   asm("movl	_dest,r7");	/* load dest register */
	   asm("mnegw	_source+2,r7");	/* memory to register */
	   asm("movpsl	_psw");			/* Save psw		*/
	   asm("movw	r7,_dest+2");	/* load dest location */
	    	   }
	if (index==3) {
	   asm("movl	$0xa,_subtst");
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_savvec4");
	   asm("movl	_source,r6");		/* load source register */
	   asm("movl	_dest,r7");	/* load dest register */
	   asm("mnegw	r6,r7");	/* register to register */
	   asm("movpsl	_psw");			/* Save psw		*/
	   asm("movw	r7,_dest+2");	/* load dest location */
	    	   }
	if (index==4) {
	   asm("movl	$0xb,_subtst");
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_savvec4");
	   asm("movl	_dest,r7");	/* load dest register */
	   asm("mnegw	_source+2,r7");	/* data to register */
	   asm("movpsl	_psw");			/* Save psw		*/
	   asm("movw	r7,_dest+2");	/* load dest location */
	    	   }
	if (index==5) {
	   asm("movl	$0xc,_subtst");
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_savvec4");
	   asm("mnegw	_source+2,_dest+2");	/* data to memory	*/
	   asm("movpsl	_psw");			/* Save psw		*/
	    	   }
	   psw &= FLAGS;	/* Mask out all bits except flag bits	*/
	   if (dest != expw[index])
		{
		asm("movl	$1,_ercode");	/* error data miscompare */
		if (scoplp) longjmp();
	        error(dest,expw[index],sourcew[index],INITIALW);
		} 
	   if (source != sourcew[index])
		{
		asm("movl	$3,_ercode");	/* error operand miscompare */
		if (scoplp) longjmp();
	        error(source,sourcew[index],sourcew[index],INITIALW);
		} 
	   if (psw != exp_psw[index])
		{
		asm("movl	$2,_ercode");	/* error flag miscompare */
		if (scoplp) longjmp();
	        error(psw,exp_psw[index],sourcew[index],INITIALW);
		}
		if (force_lp) longjmp();
	  break;
	  }
}


static mnegb()			/* move negated byte test */
{
      for (index = 0; index < MAX_PATTERNS; index++) t_mnegb();
}


static	t_mnegb	()
{
	for (;;)
	  { 
	   setjmp();
	   asm("mn3:	movab	mn3,_stpc");
	   dest = INITIALB;	/*initialize destination, source, & psw	*/
	   source = sourceb[index];
	if (index==0) {
	   asm("movl	$0xd,_subtst");
	   asm("movw	_index,r11");
	   asm("shll 	$16,_flag_value[r11],_savvec4");
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_savvec4");
	   asm("mnegb	_source+3,_dest+3");	/* memory to memory */
	   asm("movpsl	_psw");	/*save psw				*/
	    	   }
	if (index==1) {
	   asm("movl	$0xe,_subtst");
	   asm("movw	_index,r11");
	   asm("shll 	$16,_flag_value[r11],_savvec4");
	   asm("movl	_dest,r7");		/* load dest register */
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_savvec4");
	   asm("mnegb	_source+3,r7");		/* memory to register */
	   asm("movpsl	_psw");	/*save psw				*/
	   asm("movb	r7,_dest+3");		/* reload dest location */
	    	   }
	if (index==2) {
	   asm("movl	$0xf,_subtst");
	   asm("movw	_index,r11");
	   asm("shll 	$16,_flag_value[r11],_savvec4");
	   asm("movl	_source,r6");		/* load source register */
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_savvec4");
	   asm("mnegb	r6,_dest+3");		/* register to memory */
	   asm("movpsl	_psw");	/*save psw				*/
		   }
	if (index==3) {
	   asm("movl	$0x10,_subtst");
	   asm("movw	_index,r11");
	   asm("shll 	$16,_flag_value[r11],_savvec4");
	   asm("movl	_dest,r7");		/* load dest register */
	   asm("movl	_source,r6");		/* load source register */
	   asm("bicpsw	$FLAGS");
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_savvec4");
	   asm("mnegb	r6,r7");		/*  register to register */
	   asm("movpsl	_psw");	/*save psw				*/
	   asm("movb	r7,_dest+3");		/* reload dest location */
		   }
	if (index==4) {
	   asm("movl	$0x11,_subtst");
	   asm("movw	_index,r11");
	   asm("shll 	$16,_flag_value[r11],_savvec4");
	   asm("movl	_dest,r7");		/* load dest register */
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_savvec4");
	   asm("mnegb	_source+3,r7");		/* data to register */
	   asm("movpsl	_psw");	/*save psw				*/
	   asm("movb	r7,_dest+3");		/* reload dest location */
	    	   }
	if (index==5) {
	   asm("movl	$0x12,_subtst");
	   asm("movw	_index,r11");
	   asm("shll 	$16,_flag_value[r11],_savvec4");
	   asm("bicpsw	$FLAGS");
	   asm("bispsw	_savvec4");
	   asm("mnegb	_source+3,_dest+3");		/* data to memory */
	   asm("movpsl	_psw");	/*save psw				*/
		   }
	   psw &= FLAGS;	/*mask out all bits except flag bits	*/
	   if (dest != expb[index])
		{
		asm("movl	$1,_ercode");	/* error data miscompare */
		if (scoplp) longjmp();
	        error(dest,expb[index],sourceb[index],INITIALB);
		} 
	   if (source != sourceb[index])
		{
		asm("movl	$3,_ercode");	/* error operand miscompare */
		if (scoplp) longjmp();
	        error(source,sourceb[index],sourceb[index],INITIALB);
		} 
	   if (psw != exp_psw[index])
		{
		asm("movl	$2,_ercode");	/* error flag miscompare */
		if (scoplp) longjmp();
	        error(psw,exp_psw[index],sourceb[index],INITIALB);
		}
		if (force_lp) longjmp();
	   break;
	   }
}



unix.superglobalmegacorp.com

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