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

Run a .spim file using spim in Ubuntu

For Some purpose , I am writing a MIPS file for finding the second largest element of an array How do I run it to get the output? I need the command lines for spim stimulator Iam using Ubuntu 16.04 xenial by the way
2
votes
1 answer

MIPS questions about writing assembly to call functions on an array

I currently am taking a course in assembly and am having trouble with the following assignment. Write a program that reads (with an appropriate prompt) a sequence of 20 integers and stores them in an array, and then calls the following three…
Derek Mei
  • 345
  • 1
  • 3
  • 9
2
votes
1 answer

MIPS: What's the size of integer constants in MIPS?

My question is: What is the size of integer constants in MIPS? Here I found how they are used. If I have such a constant defined in my data segment and I want to calculate the size of the data segment, what size do I take for this constant:…
wonderingdev
  • 1,132
  • 15
  • 28
2
votes
1 answer

Does MIPS polling work in QtSpim? (spim simulator)

This is the school homework. I was asked to write a I/O mapping program in assembly. I am stuck at level 1 where i simply read from keyboard and write to monitor using polling method.…
william
  • 7,284
  • 19
  • 66
  • 106
2
votes
2 answers

Converting MIPS asm to hexadecimal using Spim

So I'm doing this assignment from an online CMU class where I am writing an instruction-level MIPS simulator. There are several input files given in asm format, which have to be converted into hexadecimal form in order to be read by the simulator.…
2
votes
2 answers

MIPS 'nor' usage in code

In my textbook, there are these lines of code: addu $t0, $t1, $t2 nor $t3, $t1, $zero sltu $t3, $t3, $t2 bne $t3, $zero, Overflow I understand the addu function, but when I get to the nor function and everything afterward, I don't understand what…
saturdy
  • 21
  • 1
  • 1
  • 3
2
votes
2 answers

How can I convert hex string to binary?

My problem is getting a 64-bit key from user. For this I need to get 16 characters as string which contains hexadecimal characters (123456789ABCDEF). I got the string from user and I reached characters with the code below. But I don't know how to…
FTI
  • 192
  • 2
  • 10
2
votes
1 answer

What is the different between or and ori in assembly language?

I'm doing a homework assignment and I am puzzled with which one I should use. What does the i add to the command.
2
votes
1 answer

How do I convert Mips pseudo-instructions?

I was asked to write a program in mips assembly language to perform some basic arithmetic such as converting a temperature in Celsius to Fahrenheit. I ended up receiving a poor grade on this assignment because I used pseudo-instructions. I was…
user3657834
  • 249
  • 4
  • 9
  • 21
2
votes
1 answer

MIPS shift left/shift right

I'm teaching myself MIPS and came across this piece of code: or $t0 $z0 $t1 srl $t0 1 $t0 sll $t0 1 $t0 sub $t0 $t0 $t1 the part here that interests me is that srl $t0 1 $t0 & sll $t0 1 $t0 is this correct? As i thought it would be srl $t0 $t0 1…
user3562135
  • 159
  • 2
  • 9
2
votes
3 answers

Use of Frame Pointer MIPS

i need to convert my code from stack pointer to only use frame pointer, how can i do so? i am very new to MIPS. i have this recursion C code and its MIPS code below. i am using stack pointer , how can i change it to use frame pointer? here is my C…
Justin Homes
  • 3,739
  • 9
  • 49
  • 78
2
votes
2 answers

Converting from C Loop to MIPS assembly language (bad address error)

I am writing a simple MIPS assembly code that iterates through characters of a string and finds an instance of a given substring.. First, the c code: for (i=0; i
user2492270
  • 2,215
  • 6
  • 40
  • 56
2
votes
0 answers

Read and write a string in MIPS

I'm trying to write a code which simply reads a string prints that string on screen. Here is the code I have written : .text main : la $a0, string_space li $a1, 1024 li $v0, 8 syscall li $v0, 4 syscall li $v0,…
jason
  • 6,962
  • 36
  • 117
  • 198
2
votes
0 answers

Order of delay slots MIPS

Supposed we have a load instruction followed by another load instruction, then what is the order of execution? Example: lui $t0, 0x1000 #(1) lbu $t1, ($t0) #(2) addi $t0, $t0, 1 #(3) I tested it with Spim, the result was in order (1) ->…
PiD
  • 31
  • 5
2
votes
2 answers

calculating offset

I have a question from homework. I have a BNE instruction at 0x88888888, and I need to tell what is the legal jump range. My theory is that the offset tells me I can go: From 0x8888888 - 4 * 215 To 0x88888888 + 4 * (215-1) I really don't…
boaz
  • 920
  • 1
  • 13
  • 32
1 2
3
14 15