7

I am brand new to learning MIPS assembly code, and we got our first coding assignment. I am getting an error when I run my program (which is supposed to be a tester for another function we have to write) saying

"spim: (parser) Label is defined for the second time on line 13 of file /home/jlr247/215_A2_work/jlr247-a2-A.s main: ^"

The code I have is:

.data
.align 4
_arrA: .space 400
_arrB: .space 400

.text

main:
la $t0, _arrA       #load base address of array A
la $t1, _arrB       #load base address of array B

addi $t2, $zero, 0  #$t2 = i = 0

FILL_LOOP:  #initializes all A[] values to 5, all B[] values to 10
slti $t3, $t2, 100          #check i<100
beq $t3, $zero, LOOP_DONE   #end loop when i=100
sll $t3, $t3, 2             #multiply shift by 4
add $t4, $t3, $t0           #$t4 = address of A[i]
add $t5, $t3, $t1           #$t5 = address of B[i]
addi $t6, $zero, 5
sw $t6, 0($t4)              #A[i] = 5
addi $t6, $zero, 10
sw $t6, 0($t5)              #B[i] = 10
j FILL_LOOP

LOOP_DONE:

li $v0, 1   #get ready to print test values for A[0], A[396]
lw $a1, 0($t1)
lw $a2, 396($t1)
syscall     #should print 55

li $v0, 1   #get ready to print test values for B[0], B[396]
lw $a1, 0($t2)
lw $a2, 396($t2)
syscall     #should print 1010

EXIT:

Any ideas? I'm sure it's something basic and obvious that I just haven't managed to learn yet. Thank you!

MathFlakes
  • 71
  • 1
  • 1
  • 4
  • My spim has no problem with it. I can only guess that you are not running this code yourself, and whatever system you use to do so already has the relevant label (`FILL_LOOP` ?) defined. Try to rename your label. – Jester Jul 13 '15 at 21:33
  • Thanks, I will try that! I am running it on my own machine, but like I said, I'm really a greenhorn here. – MathFlakes Jul 13 '15 at 21:36
  • If you are running this yourself, and this is all your code, then it should work (except for the fact that it has no ending). Also, which is line 13? According to my count, that's an empty line. – Jester Jul 13 '15 at 21:37
  • line 13 is the line that says "main" (I cut off my name and class info at the top). – MathFlakes Jul 13 '15 at 21:40
  • Until I saw this, I thought I had entered a kafkaesque world. – ncmathsadist May 10 '18 at 23:33

1 Answers1

16

"spim: (parser) Label is defined for the second time on line 13 of file /home/jlr247/215_A2_work/jlr247-a2-A.s main: ^"

This can happen if you use the "Load File" command twice without reinitializing the simulator in between.

To avoid this, either use "Simulator" -> "Reinitialize Simulator" followed by "File" -> "Load File", or "File" -> "Reinitialize and Load File".

Michael
  • 57,169
  • 9
  • 80
  • 125