Questions tagged [spim]

spim is a self-contained simulator that runs [tag:mips32] programs

It reads and executes assembly language programs written for this processor. Also provides a simple debugger and minimal set of operating system services. It does not execute binary (compiled) programs.

Spim implements almost the entire MIPS32 assembler-extended instruction set. (It omits most floating point comparisons and rounding modes and the memory system page tables.) The MIPS architecture has several variants that differ in various ways (e.g., the MIPS64 architecture supports 64-bit integers and addresses), which means that Spim will not run programs for all MIPS processors.

Spim implements both a terminal and windows interfaces. On Microsoft Windows, Linux, and Mac OS X, the spim program offers a simple terminal interface and the QtSpim program provides the windowing interface. The older programs xspim and PCSpim provide window interfaces for these systems as well.

Read more

System call information:

SPIM simulates a number of operating system-level functions for console I/O (e.g. print_int, print_string, read_string), file I/O (e.g. open, read), dynamic memory allocation (sbrk), etc. These functions are invoked by setting up the CPU registers according to the SPIM system call documentation and then executing a syscall instruction.

Branch delay slots:

Quoting from MIPS32™ Architecture For Programmers Volume I: Introduction to the MIPS32™ Architecture":

All branches have an architectural delay of one instruction. The instruction immediately following a branch is said to be in the branch delay slot.

In English: The instruction directly following a branch (jump) instruction will be executed before execution continues at the address you're branching to.
When writing MIPS assembly language code, care needs to be taken to fill the branch delay slots, either with NOPs, or with more meaningful instructions by changing the order or some instructions.
Note, however, that SPIM doesn't simulate branch delay slots by default. If simulating branch delay slots is desirable, it can be enabled in "Simulator" -> "Settings.." (PCSpim) or "Simulator" -> "Settings" -> "MIPS" (QtSpim). Enabling the "Bare machine" option also enables branch delay slot simulation.

218 questions
0
votes
0 answers

MIPS - Convert Word to Byte

I have (what I think) is a simple question. I have a value in a register in MIPS and I want to convert it from a word to a byte. So, for example: I have the value 123456 in register $t0 The actual value will be: 00000000 00000001 11100010 01000000 I…
user1661781
  • 327
  • 2
  • 16
0
votes
1 answer

Unintended loop termination

I'm writing a program for class that lowercases a text string. This works for the first character, but when it loops back for the second the beq $10,$0,done line always turns $10 to 0 and terminates the loop. I have no idea why. .text .globl…
liable
  • 93
  • 8
0
votes
0 answers

Forward (f) and backward (b) in label in SPIM not working

I'm using PCSpim and it doesn't seem to support labels with f and b on the end. Can anyone help me with this.
0
votes
1 answer

MIPS - is there a way to transfer the value of the flag in coprocessor 1 to integer registers of coprocessor 0?

I'm making a compiler for a school project and I am using MIPS assembly as my target code. But that's not important. I know that operations involving floating-point numbers are done in coprocessor 1 and that result of comparison instructions like…
0
votes
1 answer

How to add an argument in MIPS assembly?

So I have written a simple program for my comp arch class in MIPS assembly. We are now required to enhance this program so that it takes two arguments. If the arguments are both the same then the answer should be the same as that of the original…
0
votes
1 answer

MIPS - How to store the first 256 numbers in memory

I have to write a program in assembly language that is to store in memory the first 256 integers from 0 to 255. Here is the code I wrote (I am a beginner with the assembly language): .data memory: .space 256 .text li $t0, 0 la $s0,…
Riccardo
  • 289
  • 2
  • 5
  • 17
0
votes
0 answers

MIPS Search an Integer?

I am very new to MIPS programing and I was wondering if you could help me out. I need to write a program that converts a temperature (input by the user) from either Fahrenheit to Celsius, or Celsius to Fahrenheit depending on what the user defines.…
Kyle2595
  • 193
  • 1
  • 6
  • 15
0
votes
1 answer

Assembly - Copying an array of bytes - MIPS

First of all, I have already checked related questions to this one, yet I am still not able to overcome the problem I have with this program. What I am trying to do is, basically, take a byte[] input and duplicate it to another byte[], and print the…
Ka Putsu
  • 27
  • 7
0
votes
1 answer

Stuck in an infinite loop using jal

main: jal function1 #Exit Program li $v0, 10 syscall function1: li $s0, 0 jal function2 jr $ra function2: jal external_function beq $s0, 5, function2_end #Run loop 5 times addi $s0, $s0,…
user3718441
  • 85
  • 1
  • 3
  • 11
0
votes
2 answers

Print MIPS Register Contents

I am trying to print an unsigned integer value from a MIPS register as ASCII text to the console. In other words, let's pretend $a0 has "0x4ab3c823" in it. I want to print out "4ab3c823" to console in xSPIM. Here is my attempt. I keep getting the…
user3290553
  • 87
  • 1
  • 2
  • 9
0
votes
1 answer

Does SPIM use my CPU's registers?

When I am simulating MIPS with SPIM, when I operate on registers within the SPIM simulator am I actually using the registers on my CPU? I am running SPIM on an Intel machine.
0
votes
0 answers

Assembly Language Converting Decimal To Hex ERROR

I would like my hexadecimal output to be for example.. Decimal=45 Hexadecimal=0x2D However,currently my hexadecimal is being displayed as 213. How do I make it to display the desired hexadecimal format which is 0x2D? Can someone plz assist my…
user3505324
  • 27
  • 2
  • 10
0
votes
0 answers

Spim Crashing to Mips Reading from File

I am trying to read a file using mips assembly but every time I run the code, Spim crashes. I got the code from several websites which all had the same code and it worked fine for them. What am I doing wrong ? .data str: .asciiz…
Techflow
  • 1
  • 1
  • 3
0
votes
1 answer

Qtspim (MIPS emulator) extra code showing up?

I installed Qtspim to try out some MIPS commands. I've written a few text files, saved with a ".asm" extension, with some commands. Here's one: .text .globl main main: addi $t0, $zero, 3 addi $t1, $zero, 5 add $t2, $t0, $t1 li $v0,…
Alexis5814
  • 39
  • 1
  • 6
0
votes
0 answers

Scale i in SPIM

I have this Spim Code and there is the Scale i, What does it mean? .Data a: .word -2,35,-8,12-3,-62,-41 n: .word 7 endl: .asciiz "\n" .text main: li $t0, 0 #i li $t1, 0 #Npos li…
Samara92
  • 85
  • 11