Questions tagged [mips]

MIPS is a RISC instruction set architecture (ISA). It is commonly used in embedded devices such as set top boxes and networking gear. Many university-level computer architecture classes use the MIPS ISA due to its relative simplicity. If your question is about MIPS assembly and machine code, also add the assembly tag.

MIPS is a common RISC (Reduced Instruction Set Computer) ISA (Instruction Set Architecture), one of the first of its kind, and early MIPS is still used as an example of a classic RISC 5-stage pipeline. MIPS originally stood for "Microprocessor without Interlocked Pipeline Stages", though modern MIPS implementations now have interlocked pipeline stages.

Stack Overflow's tag gets about MIPS-like simple CPUs, and questions about programming it. In both cases, it's common to ask about simplified MIPS CPUs that don't use a branch-delay slot because that's what students are often working with, unlike actual commercial MIPS CPUs and the actual MIPS ISA. The MARS and SPIM simulators are configured by default to simulate a MIPS without branch-delay. (And the majority of MIPS assembly programming questions on Stack Overflow are about programming in that environment with their toy system calls as well, which implement things like print integer or read integer, things which on a real-world system would be done by C library functions.)

MIPS processors have two flavours: both big-endian and little-endian (often referred to as mipsel), so it might be useful to apply one of those tags as well. Many common modern System-on-chip processors that run Linux and are often found in devices such as consumer routers / Wi-Fi devices, IP cameras and other embedded systems employ MIPS architecture, including many Broadcom, Atheros and Ralink SOC.

Overview:

  • Wikipedia overview: history, CPU families, instruction format, register usage conventions
  • MIPS 32 architecture: manufacturer summary and links to reference manuals
  • MIPS 64 architecture: ditto for 64-bit CPUs (navbar has links for microMIPS, DSP ASE, MT, SmartMIPS, MIPS16, MIPS-3D, and MCU ASE)

Instruction set references:

  • MIPS32™ Architecture For Programmers Volume II: The MIPS32™ Instruction Set is the name of the document that lists and describes all instructions in the MIPS32 instruction set, along with their encodings. It can be found through the MIPS 32 architecture link above, or through a search engine.

  • MIPS64™ Architecture For Programmers Volume II: The MIPS64™ Instruction Set is the name of the same document for the MIPS64 instruction set.

  • MIPS R3000 manual (MIPS I) from 1994. Chapter 9 includes an instruction-set table (including expansions for pseudo-instructions) and C syntax for what it does. Handy to see sequences for abs and neg, as well as which instructions are real machine instructions.

  • See MIPS Run, especially Chapter 8. Complete Guide to the MIPS Instruction Set. Table 8.6 has encodings and when each instruction was introduced. (MIPS II, III, IV, and some special instructions on specific MIPS chips.) It includes TLB-maintenance instructions, MIPS II branch-likely instructions (branch-delay slot NOPed when not taken), and floating point (FP) instructions. It's a real book, so it has whole sections of explanation of how to use / how it works / why it makes sense for things like the unaligned-load instructions. But it doesn't have MIPS32 or anything newer than MIPS IV, it seems.

  • Instruction-set quick reference: MIPS Green sheet from Patterson & Hennessy's textbook. This is quite good, but is not complete even for classic MIPS I integer instructions. It omits real machine instructions including at least bgezal, and even non-linking compare-reg-against-zero instructions bltz/blez/bgtz/bgez. This video by University of Illinois professor Geoffrey Herman walks through how to read the notation for what each instruction does, and what the machine encoding is.

Running / debugging MIPS assembly code:

University / college courses that involve MIPS assembly language programming often make use of MIPS simulators such as or to allow students to run their programs. These simulators include debugging features like single-stepping, breakpoints, and register/memory viewers, that helps developers understand the runtime behaviour of their code.

Before posting a question asking for debugging help you should attempt to debug your program yourself. Even if you're unsuccessful in finding the bugs, your initial debugging attempt will probably have helped you narrow down the potential problem sources, and get a better understanding of your own code. Your findings should be detailed in your question, so that people attempting to answer your question won't have to duplicate your work.


Useful / basic Q&As about assembly programming

Q&As about internal data-paths / CPU-architecture / ISA-design

5808 questions
192
votes
13 answers

Error "gnu/stubs-32.h: No such file or directory" while compiling Nachos source code

I am trying to install Nachos on my laptop and I have Ubuntu 11.04 on the laptop. The code is in C and so to build it I assume I will need cross compiler. This is where my problem is. I downloaded the source code of the MIPS cross compiler using…
Ashish Agarwal
  • 14,555
  • 31
  • 86
  • 125
112
votes
10 answers

Why is x86 ugly? Why is it considered inferior when compared to others?

I've been reading some SO archives and encountered statements against the x86 architecture. Why do we need different CPU architecture for server & mini/mainframe & mixed-core? says "PC architecture is a mess, any OS developer would tell you…
claws
  • 52,236
  • 58
  • 146
  • 195
75
votes
5 answers

CMake: The C Compiler is not able to compile a simple test program

I am trying to cross-compile the Azure IoT SDK C for a Mips processor. Cross-compiling an older version of the same SDK using an older version of CMake (2.8.12.2) works just fine, so I doubt it's the code itself. I am guessing it's the Mips GCC…
Kagemand Andersen
  • 1,470
  • 2
  • 16
  • 30
56
votes
3 answers

What is MIPS system image in Android SDK manager?

With each SDK, I have a solution of installing MIPS system image. What is it? What does it do and when will someone use it? What will happen if I do not install it?
sandalone
  • 41,141
  • 63
  • 222
  • 338
55
votes
4 answers

What is the difference between unconditional branch and unconditional jump (instructions in MIPS)?

You may look into Wikipedia or short summary for students. Everybody says that there are two instructions for the same thing. But nobody tells why?
Val
  • 1
  • 8
  • 40
  • 64
43
votes
1 answer

MIPS assembly language - temporary register vs saved registers

So far I have been using registers $s0-$s9 and same way as registers $t0-$t9. I have been told and read countless forum posts and paragraphs here and on Google explaining the difference, but with no coding examples. I'm told I should see the…
shawn a
  • 799
  • 3
  • 13
  • 21
39
votes
2 answers

Difference between "move" and "li" in MIPS assembly language

I was practicing converting C code into MIPS assembly language, and am having trouble understanding the usage of move and li in variable assignment. For example, to implement the following C line in MIPS: int x = 0; If I understand it correctly (I…
user2492270
  • 2,215
  • 6
  • 40
  • 56
36
votes
4 answers

How to Calculate Jump Target Address and Branch Target Address?

I am new to Assembly language. I was reading about MIPS architecture and I am stuck with Jump Target Address and Branch Target Address and how to calculate each of them.
user379888
36
votes
1 answer

Assembly Files: Difference between .a .s .asm

In the MIPS simulator "QTSpim", three types of files are accepted: .a .s .asm Is there a difference between those filetypes, and if yes, what is the difference?
Nicolas Brauch
  • 497
  • 1
  • 4
  • 10
31
votes
6 answers

What's the relative speed of floating point add vs. floating point multiply

A decade or two ago, it was worthwhile to write numerical code to avoid using multiplies and divides and use addition and subtraction instead. A good example is using forward differences to evaluate a polynomial curve instead of computing the…
J. Peterson
  • 1,996
  • 1
  • 24
  • 21
29
votes
3 answers

In MIPS, what are HI and LO

I'm reading about division in MIPS and I've found that div Divides $s by $t and stores the quotient in $LO and the remainder in $HI https://web.archive.org/web/20201111203150/http://www.mrc.uidaho.edu/mrc/people/jff/digital/MIPSir.html And…
hodgesmr
  • 2,765
  • 7
  • 30
  • 41
28
votes
14 answers

MIPS - Is it important?

My question: Is the MIPS programming language that beneficial to know? I'm a CS student and am taking an assembly class which focuses on MIPS. I'm very comfortable writing in high level languages, but MIPS has me a little bit down. Is MIPS something…
user17083
  • 415
  • 1
  • 6
  • 8
27
votes
7 answers

MIPS processors : Are they still in use? Which other architecture should I learn?

I've been programming for x86 & x86-64 in assembly language for few months. Now, I want to move on to some different kind of processors. MIPS, SPARC, PowerPC, Itanium, ARM of these I found ARM is being widely use. But the books I see that…
claws
  • 52,236
  • 58
  • 146
  • 195
25
votes
5 answers

Difference between add and addu

I am confused about the difference between add and addu. The MIPS instruction reference says: add (with overflow) add unsigned (no overflow) My understanding is to use add with signed operands and addu with unsigned operands. But let's consider…
collimarco
  • 34,231
  • 36
  • 108
  • 142
25
votes
5 answers

What is the point of delay slots?

So from my understanding of delay slots, they occur when a branch instruction is called and the next instruction following the branch also gets loaded from memory. What is the point of this? Wouldn't you expect the code after a branch not to run in…
James
  • 706
  • 3
  • 8
  • 16
1
2 3
99 100