vins.c 3.38 KB
#include <stdio.h>
#include <vudefs.h>
/**************************************************************************
 * Used for vins_{T,Q,N}, vext_{T,Q,N}
 *          ==========================
 *
 * Check_Vins  (tno, Op,  rMp, vS, vT, vT_El, vD, vDexp, vTemp)
 *
 **************************************************************************/

char *Templ_vins_frmt = "( %2d, %s, $26, $v%-d, $v%-d, $v%-d%-s, $v%-d, $v%-d, $v%-d)\n";


vins(fp)
FILE *fp;
  {
    int         i,j,triple,quad,nibble, insert; 
    i16         si, ti;
    i32         di;
    u16         d_tmp[8];
    u16		Tmask0,Tmask1,Tmask2,Tmask3,Qmask0,Qmask1,Qmask2,Qmask3;
    u8          dtmp;
  
    triple = optab[opindex].enu_name==VINS_T ||
	     optab[opindex].enu_name==VEXT_T; 

    quad =   optab[opindex].enu_name==VINS_Q ||
	     optab[opindex].enu_name==VEXT_Q; 

    nibble = !triple && !quad;

    insert = optab[opindex].enu_name==VINS_T ||
	     optab[opindex].enu_name==VINS_Q || 
	     optab[opindex].enu_name==VINS_N;

    Tmask0 = 0xf800; Tmask1 = 0x07c0; Tmask2 = 0x003e; Tmask3 = 0x0001;
    Qmask0 = 0xf000; Qmask1 = 0x0f00; Qmask2 = 0x00f0; Qmask3 = 0x000f;
 
    for (i=0; i<8; i++) {

        si = (i16) vs[i];
        ti = (i16) vt[i]; /* vector always */

	el &= 0x7;

	d_tmp[i] = (i%4==0) ? si&ti : 
	           (i%4==1) ? si|ti :
	           (i%4==2) ? si^ti : ~(si^ti);

	if (insert)
	   if (triple)
	     {
	      dtmp = (u8) (si>>10) & 0x1f;

	           if (el==0) vd[i] = (ti & ~Tmask0) | (dtmp << 11);
	      else if (el==1) vd[i] = (ti & ~Tmask1) | (dtmp << 6);
	      else if (el==2) vd[i] = (ti & ~Tmask2) | (dtmp << 1);
	      else if (el==3) vd[i] = (ti & ~Tmask3) | ((dtmp >> 4) & 0x1);
	     }
	   else
	     {
	      dtmp = (quad) ?  ((u8) (si>>11)&0xf) : ((u8) si&0xf);

	           if (el==0) vd[i] = (ti & ~Qmask0) | (dtmp << 12);
	      else if (el==1) vd[i] = (ti & ~Qmask1) | (dtmp << 8);
	      else if (el==2) vd[i] = (ti & ~Qmask2) | (dtmp << 4);
	      else if (el==3) vd[i] = (ti & ~Qmask3) |  dtmp;
	     }
	else /*ext*/ 
	   if (triple)
	     {
	           if (el==0) dtmp = (u8) ((si >> 11) & 0x1f);
	      else if (el==1) dtmp = (u8) ((si >>  6) & 0x1f);
	      else if (el==2) dtmp = (u8) ((si >>  1) & 0x1f);
	      else if (el==3) dtmp = (u8) ((si & 0x01)<<4);

	     vd[i] = dtmp<<10;
	     }
	   else
	     {
	           if (el==0) dtmp = (u8) ((si >> 12) & 0xf);
	      else if (el==1) dtmp = (u8) ((si >>  8) & 0xf);
	      else if (el==2) dtmp = (u8) ((si >>  4) & 0xf);
	      else if (el==3) dtmp = (u8) ((si >>  0) & 0xf);

	           if (quad)       vd[i] = dtmp<<11;
	     else  if (dtmp & 0x8) vd[i] = 0xfff0 | dtmp; 
	     else		   vd[i] =          dtmp;
		
	     }
       } /*for*/
       
       if (data_pntr < (2048 - 100)) 
         {
           /* initidLize data segment starting at data_pntr */
           /* SRC, TRGT, RES, RES_ACCH, RES_ACCM, RES_ACCL */
           for (i=0;i<8;i++) {data[data_pntr++] = vs[i];}
	   for (i=0;i<8;i++) {data[data_pntr++] = vt[i];}
           for (i=0;i<8;i++) {data[data_pntr++] = vd[i];}
           for (i=0;i<8;i++) {data[data_pntr++] = d_tmp[i];}
	 }
       
	 fprintf(fp,optab[opindex].op_tmplt); 
         fprintf(fp,Templ_vins_frmt,
		      	test_num, 
			optab[opindex].name,
		      	regtab[SRC].rnum,
		      	regtab[TRG].rnum,
		      	regtab[TRG].rnum,el_sf,
		      	regtab[DST].rnum,
		      	regtab[DST_EXP].rnum,
		      	regtab[TEMP].rnum
			);


}/*vins*/