0

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
Ford O.
  • 1,394
  • 8
  • 25
  • 1
    That code appears to be written to be assembled with the GNU assembler. It's not compatible with SPIM. The `.word` directive is not a problem, and doesn't cause a syntax error for me with QtSpim on Windows. However, all those `#define` lines will be seen as comments by SPIM, `.end` and `.ent` have no meaning to SPIM as far as I know, and a SPIM program needs to have a `main` label. – Michael Mar 12 '17 at 16:08
  • 1
    If you want to use MIPS assembly (as opposed to x86), take a look at MARS (http://courses.missouristate.edu/KenVollmar/mars/), I find it much easier to use than SPIM. – Zack Mar 13 '17 at 11:26
  • if you want to learn computer architecture instead of learning to futz around with tools, just run the recommended tools on the recommended distribution. – markgz Mar 13 '17 at 17:33

1 Answers1

0

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
cmar8919
  • 26
  • 3