I have a simple project to do and I think it's working fine, but I have these problems:
Even though I have declare this:
.data
.msg:.asciiz "Give a number: " <-
.text2:.asciiz "x==-5"
.text1:.asciiz "Array is full"
I get a message saying: The following symbols are undefined: msg
And in the others messages text2 and text1 when they executed I'm getting weird symbols back. Why?
This is my code:
.data
.msg:.asciiz "Give a number: " #messages <-UNDEFINED MESSAGE
.text2:.asciiz "You typed -5"
.text1:.asciiz "Array is full"
.align 2
a:.space 20 #array for 5 integers
.text
.globl main
.globl loop
.globl loop2
.globl end1
.globl end2
main:
addi $14,$0,5 #t=5
addi $15,$0,-5 #f=-5
addi $16,$0,0 #i=0
addi $17,$0,0 #x=0
la $18,a
addi $2,$0,4 #Give a number:
la $4,msg
syscall
loop: #for
beq $16,$14,end1 #if i==5, end
addi $2,$0,5 #take number from console
syscall
add $17,$2,$0 #add it to array
sw $17, 0($18)
addi $18,$18,4 #change array
beq $17,$15,end2 #if x==-5, end
bne $16,$14,loop2 #if i!=5, go to loop2
loop2:
addi $16,$16,1 #i++
addi $2,$0,4 #Give a number:
la $4,msg
syscall
j loop #jumb to first loop
end1: #if i==5
addi $2,$0,4 #"Array is full"
la $4,text1
syscall
end2: #if x==-5
addi $2,$0,4 #"You typed -5"
la $4,text2
syscall