This looks like a place for a counting loop.
Let
us create just eight nodes.
Create the first node (the head) outside
of the loop so that its address can easily be
copied to the field first
.
After doing that,
the succeeding nodes are created in the loop body,
one per iteration.
Here is the first part of the code:
main: # create the first node li $v0,9 # allocate memory li $a0,8 # 8 bytes syscall # $v0 <-- address move $s1,$v0 # $s1 = &(first node) # copy the pointer to first sw $s1,first # initialize the first node li $t0,1 # store 1 sw $t0,0($s1) # at displacement 0
After doing this, the picture is:
Next, concentrate on just the counting loop.
All it has to do is count seven times,
More Blanks!