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

MIPS (SPIM) : debugging nested sub-routines

I am trying to write a MIPS program that will convert a roman numeral (entered as a string of ascii characters) into its decimal value. There's an I/0 component in that the user is prompted for an input, (limited) validity checks are performed, and…
0
votes
1 answer

how to use a predefined integer value in spim

I have written this section of code but have hit a problem: line 37 column 5: "x": operand is of incorrect type but I have declared it and called it correctly, have I not,? just the same as with the .ascizz data stored at $t1 and $t2 I know that…
0
votes
0 answers

'SPIM: (parser) syntax error'

Excuse me I'm using a MIPS simulator. Occurs that when I'm trying to open the text file that contains my code in the simulator appears me this message: spim: (parser) syntax error on line 35 of file /home/v-wrampht3r/Desktop/MIPS.s mult $s4,…
0
votes
1 answer

print an array in reverse order, assembly

so as i was last said in my previous question: I have an exercise in my univercity and i would like to have some help! first of all i'm new in mips language! So, my exercise is asking to make a programm in qtSpim which it will read 8 integers from…
coding girl
  • 9
  • 1
  • 2
0
votes
0 answers

matrix mips binary string

i am new to assembly and i have to write a program in MIPS that read string as an input,and use it as 32*32 binary matrix M(first 4 bytes is the first row in the matrix) and prints to the screen M^2(matrix is modulo 2). i tried by using syscall and…
Matan
  • 109
  • 2
  • 13
0
votes
1 answer

Generating a machine code using SPIM

I have to do an assignment which consists of developing a simulator for MIPS instructions. To test this simulator I need as inputs a code machine or a hedump code of an assembly file. I tried to use SPIM on Linux but when I check the help menu I can…
user3076262
  • 5
  • 1
  • 4
0
votes
0 answers

branch instructions, MIPS (using bare mode only)

I wonder if anyone knows if beq looks only at a specific bit (LSB) when branching to lable or does it look at the value of the entire register? I am trying to implement multiplication routine register t1 has 5(0x0000 0101) i am loading only a…
gps
  • 61
  • 1
  • 2
  • 4
0
votes
1 answer

Algorithmic Issue in MIPS

I'm rewriting my answer(s) to Project Euler questions in MIPS assembly, and I can't get this one to output the correct answer. I've gone over the code for the past hour, and I can't figure out what's wrong with my approach (as I am getting 33165…
Andy
  • 3,132
  • 4
  • 36
  • 68
0
votes
1 answer

MIPS (Bare Mode) String Won't Print

Recently while starting to learn MIPS in university, I've come across a problem while trying to print 1 string, accept a user input, and then print another string and accept a user input. Both user inputs should be stored to registers a0 and a1…
D Evans
  • 3
  • 4
0
votes
1 answer

Using QtSpim on OSX, MIPS error: "unknown character" for simple ascii declaration

I am taking my first ever Architecture class and I was given the snippet below of code to test and learn. Unfortunately, when I run the darn thing I get this error message: spim: (parser) Unknown character on line 2 of file…
mklemos
  • 69
  • 1
  • 7
0
votes
0 answers

Accessing the x number of characters in a string (MIPS)

I have this code: .text .globl __start __start:li $v0,8 li $a1,20 la $a0,str syscall print_str:li $v0,4 syscall print_endl:la $a0,Endl syscall la $a0,str sb $zero,5($a0) # <--------- # print_5chars: syscall Exit:li $v0,10 …
Trojax
  • 25
  • 1
  • 1
  • 6
0
votes
0 answers

I'm trying to ask the user to input a list of 5 words and reprint them is MIPS using Qtspim but the output gives me 5 lines of "|"

.data N: .space 100 arr: .space 5 iMsg: .asciiz "Enter a series of 5 formulae: \n" oMsg: .asciiz "The values are: \n" cr: .asciiz "\n" .text main: # ouput the prompt li $v0,4 la $a0,iMsg …
Tia
  • 79
  • 2
  • 9
0
votes
0 answers

removing leading charactor in a string and work with the rest

I am new to mips and have an assignment in which I'm required to convert a string into an integer. The catch is that I my input string is prefixed with an arbitrary non-numeric character that must be removed and then 5 added to resulting integer.…
Jon Sn0w
  • 3
  • 2
0
votes
1 answer

Getting bytes from user inputted integers

So I can manage to get the user inputted integer into $v0, then I use la $t0 ($v0) and I store the integer entered into $t0. How would I try to get the first byte of the interger from $t0. Every time I try to use lb $t1 0($t0) I get an error:…
Torched90
  • 305
  • 1
  • 3
  • 18
0
votes
0 answers

Loop through table, compare numbers and show lowest value

I need to loop through a fixed length array, and while looping find the lowest value and print it. Initially have: .text main: li $s0,0 lw $t4,l lw $s2,TABLE FOR_LOOP: bge $s0,$t4,END_FOR # define loop boundary lw $t1,($s2) …