MIPS R4000 disassembly cheatsheet

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Locked
TerryMathews
Posts: 19
Joined: Thu Mar 31, 2005 5:35 am

MIPS R4000 disassembly cheatsheet

Post by TerryMathews »

Dunno, I may be the only person that uses this, but it comes in handy for searching through binaries with hex editors like XVI32...

Conventions:
X means variable.
+ means or. (0+8) means 0 or 8, X000 in binary.
- means through. (0-3) means 0+1+2+3, 00XX in binary.

Code: Select all

R4000 ASM OPCODES (hex)
ADD     = 0x0(0-3)(0-F)(0-F)(0-F)(0+8)20
ADDI    = 0x2(0-3)(0-F)(0-F)(0-F)(0-F)(0-F)(0-F)
ADDIU   = 0x2(4-7)(0-F)(0-F)(0-F)(0-F)(0-F)(0-F)
ADDU    = 0x0(0-3)(0-F)(0-F)(0-F)(0+8)21
AND     = 0x0(0-3)(0-F)(0-F)(0-F)(0+8)24
ANDI    = 0x3(0-3)(0-F)(0-F)(0-F)(0-F)(0-F)(0-F)
BREAK   = 0x0(0-3)(0-F)(0-F)(0-F)(0-F)(0+4+8+c)D
CACHE   = 0xB(c-F)(0-F)(0-F)(0-F)(0-F)(0-F)(0-F)
DIV     = 0x0(0-3)(0-F)(0-F)001A
DIVU    = 0x0(0-3)(0-F)(0-F)001B
JUMP    = 0x0(8-B)(0-F)(0-F)(0-F)(0-F)(0-F)(0-F)
JAL     = 0x0(C-F)(0-F)(0-F)(0-F)(0-F)(0-F)(0-F)
JALR    = 0x0(0-3)(0+2+4+6+8+A+C+E)0(0-F)(0+8)09
JR      = 0x0(0-3)(0+2+4+6+8+A+C+E)00008
LB      = 0x8(0-3)(0-F)(0-F)(0-F)(0-F)(0-F)(0-F)
LBU     = 0x9(0-3)(0-F)(0-F)(0-F)(0-F)(0-F)(0-F)
MULT    = 0x0(0-3)(0-F)(0-F)0018
MULTU   = 0x0(0-3)(0-F)(0-F)0019
NOR     = 0x0(0-3)(0-F)(0-F)(0-F)(0+8)27
OR      = 0x0(0-3)(0-F)(0-F)(0-F)(0+8)25
ORI     = 0x3(4-7)(0-F)(0-F)(0-F)(0-F)(0-F)(0-F)
SYNC    = 0x0000000F
SYSCALL = 0x0(0-3)(0-F)(0-F)(0-F)(0-F)(0+4+8+C)C
XOR     = 0x0(0-3)(0-F)(0-F)(0-F)(0+8)26
XORI    = 0x3(8-B)(0-F)(0-F)(0-F)(0-F)(0-F)(0-F)
ver.1
Does not address coprocessor, double, half, traps, etc. Just the basics.

R4000 manual
Last edited by TerryMathews on Sun Apr 03, 2005 4:47 pm, edited 5 times in total.
TerryMathews
Posts: 19
Joined: Thu Mar 31, 2005 5:35 am

Post by TerryMathews »

Code: Select all

R4000 ASM OPCODES (bin)
ADD     = 000000XXXXXXXXXXXXXXX00000100000
ADDI    = 001000XXXXXXXXXXXXXXXXXXXXXXXXXX
ADDIU   = 001001XXXXXXXXXXXXXXXXXXXXXXXXXX
ADDU    = 000000XXXXXXXXXXXXXXX00000100001
AND     = 000000XXXXXXXXXXXXXXX00000100100
ANDI    = 001100XXXXXXXXXXXXXXXXXXXXXXXXXX
BREAK   = 000000XXXXXXXXXXXXXXXXXXXX001101
CACHE   = 101111XXXXXXXXXXXXXXXXXXXXXXXXXX
DIV     = 000000XXXXXXXXXX0000000000011010
DIVU    = 000000XXXXXXXXXX0000000000011011
JUMP    = 000010XXXXXXXXXXXXXXXXXXXXXXXXXX
JAL     = 000011XXXXXXXXXXXXXXXXXXXXXXXXXX
JALR    = 000000XXXXX00000XXXXX00000001001
JR      = 000000XXXXX000000000000000001000
LB      = 100000XXXXXXXXXXXXXXXXXXXXXXXXXX
LBU     = 100100XXXXXXXXXXXXXXXXXXXXXXXXXX
MULT    = 000000XXXXXXXXXX0000000000011000
MULTU   = 000000XXXXXXXXXX0000000000011001
NOR     = 000000XXXXXXXXXXXXXXX00000100111
OR      = 000000XXXXXXXXXXXXXXX00000100101
ORI     = 001101XXXXXXXXXXXXXXXXXXXXXXXXXX
SYNC    = 00000000000000000000000000001111
SYSCALL = 000000XXXXXXXXXXXXXXXXXXXX001100
XOR     = 000000XXXXXXXXXXXXXXX00000100110
XORI    = 001110XXXXXXXXXXXXXXXXXXXXXXXXXX
ver.1
User avatar
Saotome
Posts: 182
Joined: Sat Apr 03, 2004 3:45 am

Post by Saotome »

i already suspected it, but just had a look at the R4000 manual and it seems that most of the opcodes for the R5900 and R4000 are the same. so you could just use the PS2 disassembler ps2dis to disassemble R4000 code.
infj
blackdroid
Posts: 564
Joined: Sat Jan 17, 2004 10:22 am
Location: Sweden
Contact:

Post by blackdroid »

or any other mips disassembler.. another useless thread.. locked.
Kung VU
Locked