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
1
vote
2 answers

Trouble installing spim on OS X

I am trying to run spim in the OS X Terminal. I am able to use QTSpim, but the spim command in Terminal does not exist yet. I'm a bit of a newbie when it comes to the Terminal (just switched from Windows) so maybe this is really obvious. First I…
Andrew Latham
  • 5,982
  • 14
  • 47
  • 87
0
votes
1 answer

Removing spaces in a string, MIPS assembly

I have a small problem with a program i'm trying to write. Basically i'm prompting a user for input. I then count the number of spaces in the string, and display the count. I also need to print out the original string with spaces removed. The…
user1307073
  • 1
  • 1
  • 1
0
votes
3 answers

Understanding recursion with MIPS assembly language

I was in class and we have/are covering recursion in Assembly Language. I felt like I understood recursion, but the more people attempt to explain it to me, the more I feel distant from it. Anyways, our last slide had a function (in C?) and the…
Sara
  • 1
  • 1
  • 2
0
votes
0 answers

Floating Point Numbers but the output is always 0

The program is running but the output is wrong. I am also getting an "Odd FP double register number" Output Example Below is the code for the program: .data prompt1: .asciiz "Enter a decimal number with at least 5 decimal places: " prompt2:…
007547
  • 1
  • 1
0
votes
1 answer

How would I go about programming the recursive sequence below in QtSpim/MIPS

I am trying to program the following sequence in MIPS/QtSpim: a(n) = a(n-1) + 2a(n-2) where a(0) = a(1) = 1 the code should prompt the user to enter the value of n and display the results in the console. I need to use recursion with nested procedure…
eng math
  • 1
  • 1
0
votes
1 answer

using stack frame to push in parameters in order to calculate Fibbonnacci sequence but keep getting a 1 as a return value

im working on a program that uses a stack frame in order to call functions recursively to help calculate the nth term of the fibonnacci sequence this is what i have so far but the output (which would be in register $t7 by the time the program stops…
0
votes
1 answer

Having trouble printing strings in MIPS using (qtSPIM)

Basically whenever I print after a certain section of code, in this case the loop, the output in SPIM's console is either an empty character (looks like a hollow square) or an empty string (several spaces). Need some help figuring out what I'm…
spencer
  • 74
  • 8
0
votes
2 answers

What is the meaning of "<" and ">" in MIPS comments?

I have recently begun learning assembly via MIPS, and I noticed that for some reason, QtSpim removes anything inside comments and between angle brackets when showing the original source in the "Text" window: [snip] sll $0, $0, 0 # this text shows…
0
votes
0 answers

Keep getting an exception 5 [address error in store] followed by unaligned address in store. How can I fix this?

My project requires me to enter an expression, convert it to postfix, and then be able to evaluate it. I got taking an input and converting it to an expression. However, while I'm trying push my integer into a stack in my evaluation procedure, I…
Rosie
  • 1
  • 1
0
votes
1 answer

how to empty all the registers already used, to restart the program in MIPS?

I am new to MIPS and I have an assignment for uni. I have a program(game) in Mips, and I am trying to write a function to restart the game after finishing. I already have my restart function but the problem is that I have to clear all the registers…
0
votes
1 answer

MIPS - SPIM parser immediate value out of range for bitwise ANDI

Was trying to test my program with SPIM and have this message spim: (parser) immediate value (-16) out of range (0 .. 65535) on line 56 of file code1.a andi $t1, $t0, 0xfffffff0 what could be the problem?
avatar
  • 3
  • 2
0
votes
1 answer

initial stack pointer is not 0x7fffffff in MIPS

I've assembled this a short MIPS assembly code using QtSPIM simulator. I am appending the code for completion: .text .globl main main: subu $sp,$sp,32 # Stack frame is 32 bytes long sw $ra,20($sp) # Save return address sw $fp,16($sp) # Save old…
sanjihan
  • 5,592
  • 11
  • 54
  • 119
0
votes
1 answer

Undefined symbol in MIPS

I got the following message after trying to run my code: The following symbols are undefined: printf Here is part of what my code looks like: main__loser: .asciiz "You lose!" (...) main__body: jal whole_grid nop jal …
0
votes
0 answers

Substitution for %hi and %lo in MIPS

lui $a0,%hi(grid) lw $v1,24($fp) nop move $v0,$v1 sll $v0,$v0,4 subu $v0,$v0,$v1 addiu $v1,$a0,%lo(grid) addu $v1,$v0,$v1 lw $v0,28($fp) nop addu $2,$3,$2 li $3,3 # 0x3 sb $3,0($2) …
0
votes
1 answer

4 input MIPS Calculator

Im new to MIPS and my friend practice program is a calculator, instead of allowing users to have 2 inputs(eg. 1 + 2 or 1 * 4) how do allow them to have 4 inputs (eg. 1 + 3 + 3 + 2 or 1 * 4 * 5 * 2). The code below is a working 2 input calculator how…
KeKDee
  • 43
  • 5