I'm writing a program using MIPS MARS assembly that does different math calculations and I'm having trouble understanding why my string values in the .data section are printing out as a block in the beginning of the program instead of individual lines. I'm also having issues with getting the values to print out next to the correct statement.
.data
NL: .asciiz "\n" #NL=new line varible kinda name
addition: .ascii "The value of a + b = \n"
subtraction: .ascii "The value of a - b = \n "
prob_3: .ascii "The value of (a + b) - 8 = \n"
prob_4: .ascii "The value of (a + b) - (c + d) = \n"
prob_5: .ascii "The value of ((a + b) + (d - c) + 17 = \n"
.text
li $s0, 8
li $s1, 8
li $s2, 16
li $s3, 8
la $a0, addition
li $v0, 4
syscall
add $t1, $s0, $s1
li $v0, 1
add $a0, $t1, $zero
syscall
la $a0, NL
li $v0, 4
syscall
la $a0, subtraction
li $v0, 4
syscall
sub $t2, $s0, $s1
li $v0, 1
sub $a0, $t2, $zero
syscall
la $a0, NL
li $v0, 4
syscall
la $a0, prob_3
li $v0, 4
syscall
subi $t3, $t1, 8
li $v0, 1
sub $a0, $t3, $zero
syscall
la $a0, NL
li $v0, 4
syscall
la $a0, prob_4
li $v0, 4
syscall
add $t4, $s2, $s3
sub $t5, $t1, $t4
li $v0, 1
sub $a0, $t5, $zero
syscall
la $a0, NL
li $v0, 4
syscall
la $a0, prob_5
li $v0, 4
syscall
sub $t6, $s3, $s2
add $t7, $t1, $t6
addi $t8, $t7, 17
li $v0, 1
add $a0, $t8, $zero
syscall
The results I'm getting:
The value of a + b =
The value of a - b =
The value of (a + b) - 8 =
The value of (a + b) - (c + d) =
The value of ((a + b) + (d - c) + 17 =
16
The value of a - b =
The value of (a + b) - 8 =
The value of (a + b) - (c + d) =
The value of ((a + b) + (d - c) + 17 =
0
The value of (a + b) - 8 =
The value of (a + b) - (c + d) =
The value of ((a + b) + (d - c) + 17 =
8
The value of (a + b) - (c + d) =
The value of ((a + b) + (d - c) + 17 =
-8
The value of ((a + b) + (d - c) + 17 =
25
and the results i'm trying to get:
The value of a + b = 16
The value of a - b = 0
The value of (a + b) - 8 = 8
The value of (a + b) - (c + d) = -8
The value of ((a + b) + (d - c) + 17 = 25
Can someone help me figure this out?