ld.c 1.65 KB
/****************************************************************
  WHAT:	RSP SCALAR UNIT TEST GENERATOR FOR LOAD BYTE
  SCCS: @(#)ld.c	1.1 03 Aug 1994
  FILE:	ld.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_LD_TCS

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

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

int LdGen(outp, ip)
    FILE *outp;
    I_TABLE *ip;
{
    int datasize = 0;

    switch (ip->vec) {
      case LDB_VEC: datasize = 1; break;
      case LDH_VEC: datasize = 2; break;
      case LDW_VEC: datasize = 4; break;
      default: fprintf(stderr,"Unrecognized vector type: LD\n"); break;
    }

    /************************************************************
      Generate Test Cases
     ************************************************************/
    OpB = DMEM_BASE;
    for (Imm=0; Imm<datasize*0x14; Imm+=datasize, CurTcNo++) {
	FILE_SPLIT {
	    Res = ip->proc(OpB,Imm);
	    GenCase();
	    UpdRegTBR();
	}
	UpdRegID();
    }

    OpB = DMEM_BASE + datasize*0x14;
    for (Imm=-datasize; Imm>-datasize*0x15; Imm-=datasize, CurTcNo++) {
	FILE_SPLIT {
	    Res = ip->proc(OpB,Imm);
	    GenCase();
	    UpdRegTBR();
	}
	UpdRegID();
    }

    return CurTcNo = 0;

}   /* LdGen */