Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is QtSPIM telling me "Label is defined for the second time"?

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!

like image 521
MathFlakes Avatar asked Jul 13 '15 21:07

MathFlakes


People also ask

What is SPIM code?

SPIM is a MIPS processor simulator, designed to run assembly language code for this architecture. The program simulates R2000 and R3000 processors, and was written by James R. Larus while a professor at the University of Wisconsin–Madison.

What is the value of a label MIPS?

Here labelValue is the value of the label, and PC is location of the beq or bne instruction plus 4 (that is, the location where the program counter would be when the branch instruction is executed – one word after the instruction itself).


Video Answer


1 Answers

"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".

like image 158
Michael Avatar answered Oct 16 '22 20:10

Michael