Subject: Re: db_interface: hanging else clause in inst_call()?
To: Jonathan Stone <jonathan@DSG.Stanford.EDU>
From: Simon Burge <simonb@telstra.com.au>
List: port-pmax
Date: 10/28/1998 16:33:06
On Tue, 27 Oct 1998 20:37:34 -0800  Jonathan Stone wrote:

> Could someone please take a look at rev 1.6 to
> sys/arch/mips/mips/db_interface.c?  
> 
> egcs warns (correctly) about missing braces in inst_call().  The
> change I committed fixes that, but I'm still not sure if its correct.
> the table in Kane suggests it is.
> 
> I'd like to get this pulled up for 1.3.3 if we can get DDB to properly
> recognise calls.

Lemme begin by saying I've never looked at this sort of stuff before,
but I'm working off the "MIPS R4000 Microprocessor User's Manual" 2nd
edition by Joe Heinrich.  I dunno what "Kane" is...

It looks like we want to return true if the instruction is one of J,
JAL, JALR or JR (all the "jump" instructions).  It seems like we don't
worry about the conditional branches here??  J and JAL have their own
opcode, and JALR and JR are "specials".  In the current code, JAL can't
be an OP_SPECIAL, and J and JALR is forgotten about altogether.  In
summary:

	J	opcode binary 000010 (OP_J)
	JAL	opcode binary 000011 (OP_JAL)
	JALR	opcode binary 000000 (special) type binary 001001 (OP_JALR)
	JR	opcode binary 000000 (special) type binary 001000 (OP_JR)

I would have thought it should look something like this:

boolean_t
inst_call(inst)
	int inst;
{
	register int rv = 0;
	InstFmt i;
	i.word = inst;

	if (i.JType.op == OP_SPECIAL) {
		if (i.RType.func == OP_JALR || i.RType.func == OP_JR)
			rv = 1;
	}
	else {
		if (i.JType.op == OP_J || i.JType.op == OP_JAL)
			rv = 1;
	}

#ifdef DEBUG_DDB
        printf("  inst_call(0x%x) returns 0x%d\n",
                inst, rv);
#endif  
        return rv;
}


Either that, or I've got everything totally buggered up :)

Simon.