Reputation: 81
So I'm supposed read and store 4 records that consist of an employee's name (String), age (int), and salary (int) into an array. I believe that I have successfully done that part, but I'm having trouble printing all of the records in successive order. Any help would be very much appreciated.
Sample Input:
emp1
1
1
emp2
2
2
emp3
3
3
emp4
4
4
Current Output:
emp1
1
1
emp1
1
1
emp1
1
1
emp1
1
1
-- program is finished running --
Upvotes: 0
Views: 98
Reputation: 58427
Before loopB
, put the address of array
into some unused register (e.g. $t2
), and then use it whenever you need to access a record:
la $t2,array
loopB:
li $v0,4 # print name
move $a0,$t2
....
li $v0, 1 # print age
lw $a0,4($t2)
....
addiu $t2,$t2,12 # point to next element
addi $t1, $t1, -1
bgtz $t1, loopB
Upvotes: 1