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

How to compare prestored string and user input string in mips

I am trying to come up with a basic "if yes then do this, if no then exit" algorithm in mips (using spim simulator). However, bne always branches off whether yes or no (y or n in this case) has been given. I am very new to mips, so I am probably…
Colton
  • 1,297
  • 14
  • 27
0
votes
1 answer

Mips char array indexing with counter

Overview of program: Input of a number 1-26, give the corresponding Capital letter too the number My logic: Set up an Array type "structure" using .byte with chars. have a counter going through the array. once the counter is equivenlt to the input…
Conor
  • 640
  • 5
  • 10
  • 21
0
votes
1 answer

How to increment byte counter in QT Spim

For instance, I have a program with this string: str: .asciiz "abcdefghijklmnopqrstuvwxyz" Then I put another letter at the end of the string by doing: la $t0, str sb $t1, 26($t0) # the letter a is stored into $t1 This makes the editted str to…
0
votes
1 answer

QT Spim Mips programming - inputting a character into a string

How would I add on a letter into a string. For instance, I have: str: .asciiz "abcdefghijklmnopqrstuvwxyz" I want to add the letter a to the end of the string to make it display "abcdefghijklmnopqrstuvwxyza" when I print out the string. I've tried…
0
votes
0 answers

MIPS - Load Word behavior

Fellow SO users I'm hoping someone could explain the behavior that I am experiencing whilst using SPIM to run my MIPS code. I'm implementing an encryption algorithm and one of the steps is loading the encryption key which is 64 bits wide. For…
Triple777er
  • 621
  • 3
  • 17
  • 30
0
votes
1 answer

MIPS User input integers into array then printing them out

Hello I have been practicing writing assembly language and I have been working on this seemingly simple code. I want to prompt the user for input then i want to take that input and put it into an array. Then i want to print out the array. I know I…
user1836715
  • 21
  • 1
  • 1
  • 3
0
votes
0 answers

Trying to add float value to Array in MIPS but getting exception 7 error

I have to write a program that allow me to add and search float numbers in 2 arrays of 20 positions each (arrays HEIGHT and RADIOUS). I'm having trouble with the adding part... I read the user input then when I try to add the first float value into…
otavio1992
  • 712
  • 2
  • 6
  • 18
0
votes
1 answer

Mips: "Hello World" encounter error

I am trying to display "Hello World" (from an example found on internet) in Mips and see how it works, but I end up with errors.I first had the following error :"spim: (parser) Label is defined for the second time on line 6 of file C:Program Files…
T4000
  • 231
  • 1
  • 7
  • 24
0
votes
2 answers

find substring and indices in mips

im trying find out substring and first occurrence indices. but something wrong. im comparing each element of pattern array and each element of string array until pointer reach to '\0'. whats the problem. algorithm is totaly wrong ? #Note: $v0 is a…
ccc
  • 93
  • 1
  • 3
  • 10
0
votes
3 answers

Why does lw return "Immediate value is too large for field:" in QtSpim?

I am running QtSpim 9.1.7 on 64-bit Windows 7. Under Simulator / Settings / MIPS I have all options ticked ("Bare Machine", "Accept Pseudo Instructions", "Enable Delayed Branches", "Enabled Delayed Loads", "Enable Mapped IO", "Load Exception…
Katherine Rix
  • 672
  • 2
  • 8
  • 18
0
votes
1 answer

MIPS la keyword

Let's say have a variable var stored at address 0x00001000 and the value of it is 10. If i did la $t2, var Would $t2 contain the address of var or the value of var. I really want to say the address, considering la stands for load address, but…
Richard
  • 5,840
  • 36
  • 123
  • 208
0
votes
1 answer

Multiply two floats registers in spim

I want to write a small program in spim that calculate the length of circumference of a circle and reads the value of radius from user ... and here is the code sw $s0, p2 l.s $f6 ,p2 li.s $f2 ,3.4 mul.s $f8, $f2, $f6 s0 is the value of radius…
0
votes
1 answer

MIPS Assembly - Instruction String to Hex

I'm working on something in Assembly where it takes a string for an instruction, such as add $t1, $t0, $t1 and prints out the instruction in hex. I scan the string piece by piece, with add being recognized first. Add has an op code of 001000 (6…
mooooooose
  • 31
  • 1
  • 4
-1
votes
1 answer

How to set the memory adress for an instruction in MIPS?

Normally, the SPIM simulator itself allocates an address to the instructions in a program. Is there some way to manually choose where to store a particular instruction?
-1
votes
1 answer

Converting Decimal to Binary and Printing in MIPS

I'm writing a simple snippet of code for an assignment and I need to convert a decimal number to binary, octal, and hexadecimal. I have it working, but I realized afterwards that because of the algorithm I'm using, I print the binary number…
IronManIngellis
  • 111
  • 1
  • 1
  • 8
1 2 3
14
15