st.c 2.15 KB
/****************************************************************
  WHAT:	RSP SCALAR UNIT TEST GENERATOR FOR LOAD BYTE
  SCCS: @(#)st.c	1.1 03 Aug 1994
  FILE:	st.c
   WHO:	Project Reality - Evan Y. Wang
   (C):	Silicon Graphics, Inc.
 ****************************************************************/
#include <stdio.h>
#include "software.h"
#include "gen.h"
#include "suregre.h"

#define MAX_TCS	MAX_ST_TCS

#define GenCase()						\
    fprintf(outp,Templ,CurTcNo,ip->name,rR,HHW(Reg[rR]),	\
	    LHW(Reg[rR]),LHW(Imm),LHW(Imm)&~3,rA,rB,		\
	    HHW(OpA),LHW(OpA),HHW(OpB),LHW(OpB),		\
	    HHW(Res),LHW(Res),rT)

PRIVATE	char *Templ =
    /* ChkSt(  n,Op,   rR,  RValH,  RValL,    Imm,ImmAlgn,   rA,   rB,   OpAH,   OpBL,   OpBH,   OpBL,   ResH,   ResL,   rT)*/
    "\tChkSt(%2d,%s,r%-2d,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,r%-2d,r%-2d,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,0x%4.4X,r%-2d)\n";

int StGen(outp, ip)
    FILE *outp;
    I_TABLE *ip;
{
    int datasize = 0;
    u32 data = 0;

    switch (ip->vec) {
      case STB_VEC: datasize = 1; data = 0x000000FF;	break;
      case STH_VEC: datasize = 2; data = 0x0000FF00;	break;
      case STW_VEC: datasize = 4; data = 0xFF000000;	break;
      default: fprintf(stderr,"Unrecognized vector type: ST\n"); break;
    }

    OpB = DMEM_BASE;
    for (Imm=0; Imm<datasize*8; Imm+=datasize, CurTcNo++) {
	OpA = 0x1001 << (Imm/datasize);
	FILE_SPLIT {
	    Res = ip->proc(OpA,OpB,Imm);
	    GenCase();
	    UpdRegTABR();
	}
	UpdRegID();
    }
    for (Imm=datasize*8; Imm<datasize*16; Imm+=datasize, CurTcNo++) {
	OpA = data << ((Imm/datasize)-8);
	FILE_SPLIT {
	    Res = ip->proc(OpA,OpB,Imm);
	    GenCase();
	    UpdRegTABR();
	}
	UpdRegID();
    }

    OpB = DMEM_BASE + datasize*16;
    for (Imm=-datasize; Imm>-datasize*9; Imm-=datasize, CurTcNo++) {
	OpA = 0x1001 << ((-Imm/datasize)-1);
	FILE_SPLIT {
	    Res = ip->proc(OpA,OpB,Imm);
	    GenCase();
	    UpdRegTABR();
	}
	UpdRegID();
    }
    for (Imm=-datasize*9; Imm>-datasize*17; Imm-=datasize, CurTcNo++) {
	OpA = data << ((-Imm/datasize)-9);
	FILE_SPLIT {
	    Res = ip->proc(OpA,OpB,Imm);
	    GenCase();
	    UpdRegTABR();
	}
	UpdRegID();
    }

    return CurTcNo = 0;

}   /* StGen */