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
1
vote
1 answer

MIPS architecture loop help required

Complete the SPIM assembly language program loop2.s. The program will calculate the sum of the elements in "numbers" whose value is less than or equal to 1000. I tried to program the code, however the output is coming , whereas i need it to be…
1
vote
1 answer

Is there a way to accelerate the resize image performance of GraphicsMagick on mips CPU?

I'm using a netgear WNDR4300 to run GraphicsMaigick to resize JPEG images. This is the cpuinfo, cat /proc/cpuinfo system type : Atheros AR9344 rev 2 machine : NETGEAR WNDR4300 processor : 0 cpu model …
culy
  • 193
  • 1
  • 2
  • 8
1
vote
0 answers

Mips do arithmetic operation before compilation

In C I could do this: #define WIDTH 200 #define HEIGHT 200 #define SIZE WIDTH*HEIGHT If I do that, the generated code doesn't have the unnecessary multiplication of WIDTH*HEIGHT, since the precompiler calculates it beforehand and replaces SIZE…
1
vote
1 answer

What's the difference between booting a linux kernel and a standalone application?

I have a MIPS based board (MediaTek mt7620) with a proprietary and closed bootloader (u-boot) with cut off a lot of functionality, like booting a standalone application. (I'm not allowed to change/reflash this bootloader, 'cause a lot of customers…
sergs
  • 123
  • 1
  • 12
1
vote
3 answers

Bit Difference between 2 binary numbers in MIPS Assembly

So I have to create an MIPS assembly program that reads 2 numbers out of 2 registers ($s0 & $s1) and calculates the number of bits that these 2 numbers differ by. And stores the result in the $s2 register. I also have to fulfill all the above with…
1
vote
1 answer

PIC/non-PIC code errors when cross compiling

This is totally outside my area of expertise, so forgive me if this seems rather elementary. I've never really worked with C, so this is a bit new to me. I've been tasked with cross-compiling the ISC's DHCP implementation into MIPS. I have the…
Parker
  • 1,082
  • 3
  • 13
  • 27
1
vote
1 answer

Data path on a single-cycle 32-bit MIPS processor

I'm doing a homework that I need to answer signal values on marked A, B, C, D, E on the data path below which is a single-cycle 32-bit MIPS processor, however I have some questions regarding to D and E, Suppose first four line has been executed,…
nihulus
  • 1,475
  • 4
  • 24
  • 46
1
vote
0 answers

How do I convert this Java code to mips in base 64 decoding?

I have currently implemented a mips programme which reads in four Base64 characters into registers $s0, $s1, $s2, $s3. I understand that decoding into base 64 characters is taking 6 bit characters and re grouping them into 8 bits. I found this Java…
Sook Lim
  • 541
  • 6
  • 28
1
vote
1 answer

MARS user input: How do I echo asterisks from user input?

I would like to save some type of passphrase from user input in MARS. When the user types, I would like it to display * instead of the typed character. As the user types, I would save each character into an array. I already have the code that saves…
weezyBee
  • 11
  • 2
1
vote
1 answer

What is meant by 'Invoke the operating system from user program'?

I'm reading through my computer organization textbook and have come across a list of events/exceptions, one of them says "Invoke the operating system from user program". What exactly does this mean? Does this refer to a system call?
1
vote
0 answers

MARS MIPS Floating Point Exception Custom Handler Does Not Work - No Handler Works

I'm attempting to cause floating point exceptions (divide by zero, odd-register, etc.) and handle them in custom handlers. If I include handlers and step into the kernel code, (cause) and (epc) are 0x00000000. If I don't include a handler, the…
1
vote
0 answers

Pipeline with and without data forwarding

I'm confused about comparing number of stall cycles of pipelining with and without data forwarding. I'll use an example to illustrate my question: For the following MIPS instructions: I1: add $t1, $t2, $t3 I2: sub $t2, $t1, $t2 Which of the…
1
vote
0 answers

Reason why I am having garbage values appear?

So when I call this function for a value in my array, it prints out a garbage value then on the next line what I actually want to print. When I enter a value not in the array it errors out. I am new to this so could be something stupid .data array:…
1
vote
0 answers

How to read and write two lines of string in MIPS?

I need to read two lines of string from file Input.txt as 15/02/1996 25/05/1332 and I don't know how to read the second string in the new line. I tried many ways and read lots of documents but I can't solve this. Any help would be highly…
Nhi Nguyen
  • 11
  • 2
1
vote
1 answer

Do I need to load from memory a base address of an array to a temporary register in this MIPS code?

I'm working on Homework and I have to translate some c code into MIPS(32-bit). I can use 3 registers $s0 for a variable x, '$s1' for a variable y and '$s3' for the base address of array 'A[]'. My goal is to be able to perform some conditional if…
Simon
  • 241
  • 2
  • 13