Subject: r3000 instruction set

From: "Mark and Janice Juszczec" <[email-masked]>
Date: Sun, 22 Feb 2004 03:02:39 +0000

Hi folks

I'm working with kaffe on a r3912 cpu. I'm getting an illegal instruction
error. I disassembled the kaffe binary and thought I'd find the offending
instruction.

Unfortunately, I found 2 different lists of r3000 assembler instructions at:

http://www.xs4all.nl/~vhouten/mipsel/r3000-isa.html
http://www.xs4all.nl/~vhouten/mipsel/appB.html

and comparing them against the list of disassembled kaffe instructions
gives 2 different results.

So, can someone recommend a definitive list of r3000 assembler instructions?

Any help would be greatly appreciated.

Mark

_________________________________________________________________
Find and compare great deals on Broadband access at the MSN High-Speed 
Marketplace. http://click.atdmt.com/AVE/go/onm00200360ave/direct/01/

---

From: Michael Uhler <[email-masked]>
Date: 21 Feb 2004 19:15:49 -0800

Unfortunately, what you want isn't the r3000 instruction list but,
instead the 3912 instruction list.  While the original r3000
instructions were well-defined, each manufacturer tended to
add or subtract certain instructions in each implementation
(creating the kind of behavior and questions that you're seeing).

So rather than asking for the list, why not just post the disassembly
and the pc of the reserved instruction?

/gmu

-- 
Michael Uhler, Chief Technology Officer
MIPS Technologies, Inc.  Email: [email-masked]
1225 Charleston Road     Voice:  (650)567-5025  FAX:   (650)567-5225
Mountain View, CA 94043  Mobile: (650)868-6870  Admin: (650)567-5085

---

From: "Kevin D. Kissell" <[email-masked]>
Date: Sun, 22 Feb 2004 10:32:58 +0100

> So, can someone recommend a definitive list of r3000 assembler instructions?

Several things here.  First,. as Mike pointed out, the 3912 is not an R3000.
It's a superset of the original R3000 "MIPS I" instruction set.  Interestingly,
while the "Appendix B" web page you cite above describes itself as listing
the MIPS I instruction, it actually lists some of the MIPS II instructions that
are implemented in the R3912.

There do seem to be some errors on the first page you cite. For example,
it calls out a "subtract unsigned" instruction, which exists, but then gives it
a non-existent opcode (subi), and incorrect semantics ("exception possible").
So I would ignore that page.  You can get an accurate description of the
MIPS32 instruction set from the MIPS Technologies Inc. web pages at
http://www.mips.com/content/Documentation/MIPSDocumentation/ProcessorArchitecture/doclibrary
though you do need to register to get access.  MIPS32 is a superset of MIPS I,
but it's a strict superset, so any instructions you see in your R3912 trace
should be documented in the MIPS32 spec, with the exeptions of RFE,
which was obsoleted by ERET in MIPS III, and the R3912 MADD/MADDU
instructions, which were superset extensions which predated the MIPS32 MADD 
instructions, and which collide with the MIPS32 CLZ instruction decode.

I spend some time working on Kaffe for MIPS a couple of years ago,
and I remember that there were some hooks to try to manage the ISA
level used.  For example, I had to fix some stuff around the use of the
MIPS IV/MIPS32 conditional move instructions where aren't available
in older cores like the R3912 - but I fixed that because I saw that it was
broken, not because I was testing on a true MIPS I/II platform.  So
someone could have screwed up something else somewhere along those lines.
Note also that the JIT3 logic has always been slightly broken for MIPS.
I spent a week or two trying to hunt it down, disassembling the generated
code buffers, and all the errors I saw *seemed* to be due to the generated
code assuming that some data structure was initialized with a pointer value
that in fact was zero.  That may not be what you're seeing, but since everyone
who actually uses Kaffe for MIPS configures it with --set-engine=intrp, 
instructions could be generated by the JIT3 code which are not compatible
with older MIPS designs, and people might not have noticed.

            Regards,

            Kevin K.

---

From: Dominic Sweetman <[email-masked]>
Date: Sun, 22 Feb 2004 12:31:35 +0000

> error. I disassembled the kaffe binary and thought I'd find the offending

Two suggestions, to make a hat-trick of responses from MIPS.  "See
MIPS Run" (I'm too modest to mention the author's name) has a pretty
accurate list of instructions covering R3000 and 39xx derivatives.

Any reasonable GNU assembler knows all the instructions there ever
were - and if you look at the table in mips-opc.c, fairly accurately
attributed to various instruction set definitions and extensions.

--
Dominic Sweetman
MIPS Technologies.

---

From: Eric Christopher <[email-masked]>
Date: Sun, 22 Feb 2004 11:13:06 -0800

> So, can someone recommend a definitive list of r3000 assembler instructions?

Other than the responses you've already gotten, likely you'll need to
compile with -march=r3900(or -mcpu=r3900 if it's an old toolchain) since
the 3900 is missing a couple of r3000 instructions iirc.

If it's the 3912 I remember it also doesn't have an fpu, but I could be
wrong there. If it is, then you need -msoft-float as well.

-eric

-- 
Eric Christopher <[email-masked]>

---

From: "Kevin D. Kissell" <[email-masked]>
Date: Sun, 22 Feb 2004 22:52:13 +0100

> the 3900 is missing a couple of r3000 instructions iirc.

The 3900 family should run MIPS I code compiled for the R3000.

> wrong there. If it is, then you need -msoft-float as well.

The 3912 has no FPU, but if you're running on any contemporary
MIPS/Linux kernel and library system, you neither need nor want
soft-float.  The kernel does FP instruction emulation.  Running soft-float
would make for faster, if larger, code, but requires that the whole
system, particularly glibc, be built for soft-float, which is rarely done
(and the last time I tried it, didin't quite work with the standard
glibc sources out-of-the-box).

---

From: "Steven J. Hill" <[email-masked]>
Date: Sun, 22 Feb 2004 22:03:17 -0500

> The 3900 family should run MIPS I code compiled for the R3000.
Yep.

> glibc sources out-of-the-box). 
Correct. I use the FP emulator in Linux for my TX3917/PR31700 stuff. I
have had no problems. Current glibc has assembly code that assumes hardware
floating point which is why building for soft-float does not work out of
the box. There are probably some patches out there to rectify that. My
personal choice, use uClibc (http://uclibc.org/) for your C runtime. I wrote
the dynamic linker loader for MIPS and would highly recommend you try it out.
I would really like to see more testing of it.

Also, I have some documents for the 3912 on my FTP site:

    ftp://ftp.realitydiluted.com/docs/Toshiba
    ftp://ftp.realitydiluted.com/docs/Philips

It should be noted that the Toshiba TX3912 and the Philips PR31700 are
identical cores. There was definitely some cross-licensing going on there.
Perhaps Kevin or Dominic would know this in more detail, but it is not
really that important.

-Steve

---

From: Eric Christopher <[email-masked]>
Date: Sun, 22 Feb 2004 19:37:29 -0800

> The 3900 family should run MIPS I code compiled for the R3000.

IIRC there were some standard MIPS I instructions that were not on the
tx39.

-eric

---

From: "Kevin D. Kissell" <[email-masked]>
Date: Mon, 23 Feb 2004 08:03:36 +0100

> the box. There are probably some patches out there to rectify that. 

It's been several years, but the last time I dealt with it, it wasn't all
that hard to fix if you knew what you were doing, but it was a couple
of days' work just the same.

> Perhaps Kevin or Dominic would know this in more detail, but it is not

I'm  not sure whether any NDAs which may or may not exist
would have expired by now, so I'll stick to a "no comment".  ;o)

---

From: "Kevin D. Kissell" <[email-masked]>
Date: Mon, 23 Feb 2004 08:11:14 +0100

> IIRC there were some standard MIPS I instructions that were not on the

I think you may be confusing MIPS I and MIPS II.  I'm pretty darn certain
that the TX39 inplemented all of MIPS I, most of MIPS II, plus a MADD 
extension.  I'm not going to go instruction counting this morning, but the
TX39 spec declares up-front that it's a superset of the R3000A.

---

From: Eric Christopher <[email-masked]>
Date: Sun, 22 Feb 2004 23:29:23 -0800

> TX39 spec declares up-front that it's a superset of the R3000A.

Me either so until I guess the guy says which instruction is at fault
we'll leave it be. :)

-eric