Search code examples
mipsspim

Mips first steps - Spim : syntax error


I am attending an university course that according to specification tries to follow book "Computer architecture a quantitative approach".

Our task was to write an insert sort in MIPS, but I don't know how should I debug my code or even compile it. School web page points to gcc-mips-elf and MipsIt from the book.

Problem is I am using arch instead of debian so gcc-mips-elf is not available and MipsIt requires emulator, so I have decided to go with native simulator QtSpim which I have found in arch database.

But when I try to execute the template from course web page, spim throws an error : syntax error on line 17 ... .word 5, 3, 4, 1, 2

#define t0 $8
#define t1 $9
#define t2 $10
#define t3 $11
#define t4 $12

#define s0 $16
#define s1 $17
#define s2 $18
#define s3 $19

  .globl    field
  .data
  .align    2

field:
  .word    5,3,4,1,2

  .text
  .globl start
  .ent start

start:
  // your code goes here
  nop
  .end start

Solution

  • The .word assembler directive reserves a single word in memory for the value that follows. The assembler won't allow a list of values as you have provided after the assembler directive. If you instead break this down into 5 separate assembler directives it should resolve the syntax error.

    Specifically, you should replace:

    .word    5,3,4,1,2

    with:

    .word    5
    .word    3
    .word    4
    .word    1
    .word    2