# TrueReality - CPU documentation                                       #
# Copyright (C) 1999 Niki W. Waibel                                     #
#                                                                       #
# This program is free software; you can redistribute it and/           #
# or modify it under the terms of the GNU General Public Li-            #
# cence as published by the Free Software Foundation; either            #
# version 2 of the Licence, or any later version.                       #
#                                                                       #
# This program is distributed in the hope that it will be use-          #
# ful, but WITHOUT ANY WARRANTY; without even the implied war-          #
# ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         #
# See the GNU General Public Licence for more details.                  #
#                                                                       #
# You should have received a copy of the GNU General Public             #
# Licence along with this program; if not, write to the Free            #
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,         #
# USA.                                                                  #
#                                                                       #
# Information about me (the author):                                    #
#   Niki W. Waibel, Reichenau 20, 6890 Lustenau, Austria - EUROPE       #
#   niki.waibel@gmx.net                                                 #


=========================================================================
 This is some sort of the CPU (Central Processing Unit?) documentation.
=========================================================================


All of this stuff was figured out by disassembling/emulating various demos
with TrueReality and hard studying of the mips manuals from:
ftp://ftp.sgi.com/
.
All things which I'm not sure about are marked with a '?'.





General things:
        There are 217 instructions:
                52 special cpu instructions
                14 regimm cpu instructions
                52 general cpu instructions
                15 cop0 (tlb/eret)
                84 cop1 (fpu)
                 0 cop2

        ... to be written.





Registers:
        ... to be written.





Instruction Formats:

        register:  r
        immediate: i
        jump:      j

          +===============================================================+
          |3 3 2 2 2 2|2 2 2 2 2|2 1 1 1 1|1 1 1 1 1|1        |           |
          |1 0 9 8 7 6|5 4 3 2 1|0 9 8 7 6|5 4 3 2 1|0 9 8 7 6|5 4 3 2 1 0|
          +-----------+---------+---------+---------+---------+-----------+
        r:|    op     |   rs    |   rt    |   rd    |   sa    |   funct   |
          +-----------+---------+---------+---------+---------+-----------+
        i:|    op     |   rs    |   rt    |           immediate           |
          +-----------+---------+---------+---------+---------+-----------+
        j:|    op     |                       target                      |
          +===============================================================+





Instruction Map:

        Opcode (bits 31-26):

         /========================================================================\ 
        ||   28-26|   0   |   1   |   2   |   3   |   4   |   5   |   6   |   7   ||
        ||=31-29=/+===============================================================||
        ||   0   ||special|regimm |   J   |  JAL  |  BEQ  |  BNE  | BLEZ  | BGTZ  ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   1   || ADDI  | ADDIU | SLTI  | SLTIU | ANDI  |  ORI  | XORI  |  LUI  ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   2   || cop0  | cop1  | cop2  |   *   | BEQL  | BNEL  | BLEZL | BGTZL ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   3   || DADDI |DADDIU |  LDL  |  LDR  |   *   |   *   |   *   |   *   ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   4   ||  LB   |  LH   |  LWL  |  LW   |  LBU  |  LHU  |  LWR  |  LWU  ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   5   ||  SB   |  SH   |  SWL  |  SW   |  SDL  |  SDR  |  SWR  | CACHE ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   6   ||  LL   | LWC1  | LWC2  |   *   |  LLD  | LDC1  | LDC2  |  LD   ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   7   ||  SC   | SWC1  | SWC2  |   *   |  SCD  | SDC1  | SDC2  |  SD   ||
         \========================================================================/ 

        SPECIAL function (bits 5-0):

         /========================================================================\
        ||     2-0|   0   |   1   |   2   |   3   |   4   |   5   |   6   |   7   ||
        ||==5-3==/+===============================================================||
        ||   0   ||  SLL  |   *   |  SRL  |  SRA  | SLLV  |   *   | SRLV  | SRAV  ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   1   ||  JR   | JALR  |   *   |   *   |SYSCALL| BREAK |   *   | SYNC  ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   2   || MFHI  | MTHI  | MFLO  | MTLO  | DSLLV |   *   | DSRLV | DSRAV ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   3   || MULT  | MULTU |  DIV  | DIVU  | DMULT |DMULTU | DDIV  | DDIVU ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   4   ||  ADD  | ADDU  |  SUB  | SUBU  |  AND  |  OR   |  XOR  |  NOR  ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   5   ||   *   |   *   |  SLT  | SLTU  | DADD  | DADDU | DSUB  | DSUBU ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   6   ||  TGE  | TGEU  |  TLT  | TLTU  |  TEQ  |   *   |  TNE  |   *   ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   7   || DSLL  |   *   | DSRL  | DSRA  |DSLL32 |   *   |DSRL32 |DSRA32 ||
         \========================================================================/

        COP0 function (bits 5-0):

         /========================================================================\
        ||     2-0|   0   |   1   |   2   |   3   |   4   |   5   |   6   |   7   ||
        ||==5-3==/+===============================================================||
        ||   0   ||   ^   | TLBR  | TLBWI |   ^   |   ^   |   ^   | TLBWR |   ^   ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   1   || TLBP  |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   2   ||   *   |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   3   || ERET  |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   4   ||   ^   |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   5   ||   ^   |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   6   ||   ^   |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   7   ||   ^   |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   |   ^   ||
         \========================================================================/

        COP1 function (bits 5-0):

         /========================================================================\
        ||     2-0|   0   |   1   |   2   |   3   |   4   |   5   |   6   |   7   ||
        ||==5-3==/+===============================================================||
        ||   0   ||  ADD  |  SUB  |  MUL  |  DIV  | SQRT  |  ABS  |  MOV  |  NEG  ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   1   ||ROUND.L|TRUNC.L|CEIL.L |FLOOR.L|ROUND.W|TRUNC.W|CEIL.W |FLOOR.W||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   2   ||  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   3   ||  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   4   || CVT.S | CVT.D |  ---? |  ---? | CVT.W | CVT.L |  ---? |  ---? ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   5   ||  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   6   ||  C.F  |  C.UN |  C.EQ | C.UEQ | C.OLT | C.ULT | C.OLE | C.ULE ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   7   || C.SF  |C.NGLE | C.SEQ | C.NGL |  C.LT | C.NGE |  C.LE | C.NGT ||
         \========================================================================/

        REGIMM rt (bits 20-16):

         /========================================================================\
        ||   18-16|   0   |   1   |   2   |   3   |   4   |   5   |   6   |   7   ||
        ||=20-19=/+===============================================================||
        ||   0   || BLTZ  | BGEZ  | BLTZL | BGEZL |   *   |   *   |   *   |   *   ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   1   || TGEI  | TGEIU | TLTI  | TLTIU | TEQI  |   *   |  TNEI |   *   ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   2   ||BLTZAL |BGEZAL |BLTZALL|BGEZALL|   *   |   *   |   *   |   *   ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   3   ||   *   |   *   |   *   |   *   |   *   |   *   |   *   |   *   ||
         \========================================================================/

        COPx rs (bits 25-21):

         /========================================================================\
        ||   23-21|   0   |   1   |   2   |   3   |   4   |   5   |   6   |   7   ||
        ||=25-24=/+===============================================================||
        ||   0   ||  MF   |  DMF  |  CF   |  ---? |  MT   |  DMT  |  CT   |  ---? ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   1   ||  BC   |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   2   ||   S   |   D   |  ---? |  ---? |   W   |   L   |  ---? |  ---? ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   3   ||  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? ||
         \========================================================================/

        COPx rt (bits 20-16):

         /========================================================================\
        ||   18-16|   0   |   1   |   2   |   3   |   4   |   5   |   6   |   7   ||
        ||=20-19=/+===============================================================||
        ||   0   ||  BCF  |  BCT  | BCFL  | BCTL  |  ---? |  ---? |  ---? |  ---? ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   1   ||  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   2   ||  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? ||
        ||-------||-------+-------+-------+-------+-------+-------+-------+-------||
        ||   3   ||  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? |  ---? ||
         \========================================================================/

           *: reserved instruction exception occurs
           ^: invalid instruction





Instructions:
        ... to be written!
