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

How do I determine or set the working directory of QtSpim?

I just want to run ANY kind of Spim programm using an Syscall for open, read and/or write a file, but that doesn´t work out. I am aware that probably my program and the file are not in the working directory of QtSpim, but I have no Idea how to…
-1
votes
1 answer

attempt to execute non-instruction

i have some code in mips assembler and i'm getting something like in the title. As you can see, i have $li $v0, 10 and syscall so does anybody know what's wrong with it? .data text0: .asciiz "Enter strng: \n" buf0: .space 100 …
zakho
  • 13
  • 2
-1
votes
1 answer

SPIM print ascii char

I have to write a little program in assembly for the MIPS architecture. To be more specific it should be a procedure which takes a register and prints the value of it. It is allowed to use everything excepted a call of print_int. My procedure does:…
Asker
  • 431
  • 5
  • 14
-1
votes
1 answer

MIPS32 SPIM: Read int then print it

I'm having trouble understanding why I am getting syntax error in line 20, sw $v0, $t0. $v0 should be the integer returned from the previous call to read int, and $t0 is a temporary register. Thanks! .data msg: .asciiz "Hello world.\n" promptint:…
MT.
  • 3
  • 2
-1
votes
1 answer

MIPS code for qtspim

Hello I'm trying to debug this code. It gives the wrong values for its registers. The code is to test some simple arithmetic and storing of values in different registers. Thank you for your help! .ent main main: addi $a0, $0, 10 # r4 = 0 +…
-2
votes
2 answers

MIPS Output Error

I have an unknown output error after entering 2nd value which is after entering base number. Hopefully,some of you could identify my error: ERROR:Instruction references undefined symbol at 0x00400060 [0x00400060] 0x102a0000 beq $1, $10, 0…
user3505324
  • 27
  • 2
  • 10
-2
votes
1 answer

Can someone help me interpret what these lines mean in MIPS?

.data 0x10000000 .align 2 Array: .word 3 6 9 12 15 18 21 24 Size: .word 8 Result: .word 0 So what does ".data" mean exactly and does "Size" correspond to the size of "Array" or is it simply another variable? Also, what does "Result" mean? Is it an…
June
  • 27
  • 4
-4
votes
1 answer

Struggling with 2D arrays in assembly

I am trying to implement the following in MIPS X is a two-dimensional array (matrix) of double-precision floating-point numbers and Y is two-dimensional array of 32-bit integers. Trying to write code for the following Z= (X[i][j] + Y[i][j]) Now I…
Bic B
  • 201
  • 2
  • 6
  • 18
1 2 3
14
15