.data head: .word 0 tail: .word 0 .text jal MakeList li $v0,10 syscall ############################################ MakeList: move $t7, $0 #initialize to 0, this will be the head move $t8, $0 #tail pointer li $v0, 5 #read an int and put it inot $t1 syscall move $t1,$v0 MakeList_1: beqz $t1, MakeList_5 li $a0,8 #malloc 8 bytes from the heap li $v0,9 syscall sw $t1, 4($v0) #put int in node sw $0, ($v0) #initialize next to null bnez $t7 MakeList_2 #empty list move $t7, $v0 #head = malloc(2) move $t8, $t7 #tail = head b MakeList_3 MakeList_2: #else not empty, add to end sw $v0, ($t8) #link to tail.next, first word in node lw $t8, ($t8) #tail = tail.next MakeList_3: li $v0, 5 syscall move $t1,$v0 #read an integer b MakeList_1 MakeList_5: sw $t7,head sw $t8,tail jr $ra