Questions tagged [mars-simulator]

MARS is an IDE and simulator for programming in MIPS assembly language, created at the Missouri State University.

Quoting from its homepage:

MARS is a lightweight interactive development environment (IDE) for programming in MIPS assembly language, intended for educational-level use with Patterson and Hennessy's Computer Organization and Design.

System call information:

MARS simulates a number of operating system-level functions for console I/O (e.g. print integer, print string, read string), file I/O (e.g. open file, read from file), dynamic memory allocation (sbrk), random number generation, etc.
These functions are invoked by setting up the CPU registers according to the MARS 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 MARS doesn't simulate branch delay slots by default. They can be enabled in the Settings menu if that is desirable.

488 questions
15
votes
1 answer

Dark theme for Mars 4.5 Mips?

I am using Mars MIPS Assembler and Runtime Simulator 4.5 for an assembly class and i find white background tiring when you stare at a screen for hours. I want to change the editor's color to a darker tone (preferably the whole window) like sublime…
Bill
  • 321
  • 6
  • 15
15
votes
2 answers

Creating (and accessing) an array in MIPS

I'm trying to create an array in MIPS Assembly, and then add all the elements together. However, when I try to assemble the following, it says Error in read_array line 1 position 7: ".word" directive cannot appear in text segment Assemble:…
hodgesmr
  • 2,765
  • 7
  • 30
  • 41
12
votes
3 answers

Understanding Assembly MIPS .ALIGN and Memory Addressing

I'm taking this course, and I'm really struggling understanding the directive .align concept. Here's an example, which I couldn't understand: I know that inside the data segment, there are addresses, starting with 0x10010000,0x10010020,etc. And I…
Sobiaholic
  • 2,927
  • 9
  • 37
  • 54
11
votes
2 answers

Reading and printing an integer in MIPS assembly language

My program is supposed to read an integer and print it back to the user, but every time it just prints 268501230, no matter what is entered. How can I fix it? .data prompt2: .asciiz "Please enter value: " array1: .space 40 array2: .space…
user2837034
  • 207
  • 1
  • 6
  • 11
10
votes
2 answers

MARS disassembly of BEQ shows a number as the branch target. What does it mean?

I have copied a picture of an assignment I have on MIPS assembly. I understand (I think) what happens in the code until the line: beq $11, $0, 3 I understand that the code now makes a PC-RELATIVE branch for the address: PC+4+3*4 But I don't…
Assaf
  • 1,112
  • 4
  • 14
  • 35
8
votes
1 answer

MIPS "la" pseudo instruciton

In MIPS, the la instruction translates into lui and ori. However, MARS Simulator does not seem to do that at all. When I dump the following machine code: .text la $a0, array la $a1, array_size lw $a1, 0($a1) .data array: .word 0:10 …
darksky
  • 20,411
  • 61
  • 165
  • 254
8
votes
3 answers

Is mars MIPS simulator Big or Little Endian

I have to determine if the mars simulator is big or little endian as homework, this seems pretty straightforward at first, but I am having some issues. First I tried storing 4 bytes in memory with .byte 0, 0, 0, 1, in memory this appears as…
Juan González
  • 177
  • 1
  • 3
  • 10
8
votes
1 answer

Tweak mips-gcc output to work with MARS without using a script

The MIPS assembly code generated by mips-gcc almost, but doesn't quite, run on the MARS_ MIPS simulator. For example: The compiler generates "j $31" instead of "jr $31" The compiler puts .align directives in the text segment, which MARS does not…
Zack
  • 6,232
  • 8
  • 38
  • 68
7
votes
1 answer

Accessing one character in a string

I am using something like SPIMS or MARS with syscall functions. I am reading in a string (and it works because I can print it out) as follows: li $v0, 8 la $a0, string li $a1, 256 syscall However, I am having a problem accessing a single character…
darksky
  • 20,411
  • 61
  • 165
  • 254
7
votes
1 answer

Reading an integer into a local variable in MIPS

How can I read an integer into a local variable in MIPS? The problem asks me to use the concept of assigning integer variables as local variables. (A question from my text book.)
Mojo_Jojo
  • 939
  • 4
  • 13
  • 26
7
votes
3 answers

Reading files with MIPS assembly

I'm trying to write a program that reads in characters from a .dat file that correspond to different colors to be displayed in the LED simulator; x = off, R = red, etc. My problem is, I cannot figure out what I'm doing wrong with opening the .dat…
CJ McAllister
  • 291
  • 3
  • 10
  • 20
7
votes
0 answers

In a MIPS assembly `addi` instruction, how is a hexadecimal immediate interpreted?

Is there is a standard or recommendation for how the addi instruction (and others) should be interpreted in assembly, when hexadecimal immediate values are used? Example: addi $t0, $zero, 0xffff I was expecting this to mean the same as addi $t0,…
Miguel
  • 658
  • 1
  • 6
  • 19
6
votes
1 answer

reading the file name from user input in MIPS assembly

I'm writing a MIPS assembly code that will ask the user for the file name and it will produce some statistics about the content of the file. However, when I hard code the file name into a variable from the beginning it works just fine, but when I…
Hassan Al-Jeshi
  • 1,450
  • 2
  • 15
  • 20
5
votes
3 answers

How to load memory address without using pseudo-instructions?

I'm trying to learn MIPS assembly language by myself using MARS simulator. For didactic reasons I'm limiting myself to not using pseudo-instructions. While trying to get the address of some data into a register, I ran into a problem because I cannot…
Trinidad
  • 2,756
  • 2
  • 25
  • 43
5
votes
2 answers

Mars MIPS Simulator not functioning, installation issues?

I have downloaded the Mars MIPS Simulator .jar file, and I have downloaded the java jdk file from oracle. Whenever I open the jar file, the IDE is there, but everything is greyed-out. I can't even edit the text in the window. When you select…
Zach
  • 85
  • 1
  • 1
  • 9
1
2 3
32 33