.data
normal: .ascii "aaa/0aab/0aac/0"
save:
.text
main:
# Load address of the string "aaa/0aab/0aac/0" into $a1
la $a1, normal
# Skip the first string "aaa/" (4bytes)
addi $a1, $a1, 4
# Load the second string "aab/0" into $a0
lw $a0, ($a1)
# Store the second string at the address of "save"
sw $a0, save
# Print the second string
# Prepare syscall code for printing a string (4)
li $v0, 4
# Load the address of the string to be printed
la $a0, save
# Make the syscall
syscall
# Exit the program
li $v0, 10
syscall
Wrote this program, it is very simple, it gets the second item from the string vector, saves it in the save adress and then prints it. It runs into an error at line 14 (sw $a0, save). What is the problem here, even my teacher cant figure it out. Is it an issue with MARS or what is it?
New contributor
David Herrezuelo Paredes is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.